NGINX 408 timeout (reading client request headers) - Stack Overflow (https://cdn.sstatic.net/Sites/stackoverflow/Img/favicon.ico?v=ec617d715196) (https://cdn.sstatic.net/Sites/stackoverflow/Img/apple-touch-icon.png?v=c78bd457575a) (https://cdn.sstatic.net/Sites/stackoverflow/Img/apple-touch-icon.png?v=c78bd457575a) (Stack Overflow) (/opensearch.xml) (https://stackoverflow.com/questions/52277929/nginx-408-timeout-reading-client-request-headers) (https://cdn.sstatic.net/Shared/stacks.css?v=bd2aba62c5a4) (https://cdn.sstatic.net/Sites/stackoverflow/primary.css?v=cc49ce762956) (Feed for question 'NGINX 408 timeout (reading client request headers)') (/feeds/question/52277929) (https://cdn.sstatic.net/Shared/Channels/channels.css?v=5981bb1a5bd7) (https://accounts.google.com/gsi/style) (site logo) Join Stack Overflow By clicking “Sign up”, you agree to our (/legal/terms-of-service/public) terms of service and acknowledge you have read our (/legal/privacy-policy) privacy policy . (8715abeb62cf6a9fe93de824cea527599cbf4e957f73c9d6615a4213f6b2728c) (1) (2.0) Sign up with Google Sign up with GitHub OR (8715abeb62cf6a9fe93de824cea527599cbf4e957f73c9d6615a4213f6b2728c) (1) () () () () () () Email Password (8+ characters (at least 1 letter & 1 number)) Sign up Already have an account? (/users/login) Log in (8715abeb62cf6a9fe93de824cea527599cbf4e957f73c9d6615a4213f6b2728c) () Skip to main content (https://stackoverflow.com) Stack Overflow (https://stackoverflow.co/) About Products (https://stackoverflow.co/teams/ai/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav-bar&utm_content=overflowai) OverflowAI (https://stackoverflow.co/teams/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=stack-overflow-for-teams) Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers (https://stackoverflow.co/advertising/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=stack-overflow-advertising) Advertising & Talent Reach devs & technologists worldwide about your product, service or employer brand (https://stackoverflow.co/teams/ai/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=overflow-ai) OverflowAI GenAI features for Teams (https://stackoverflow.co/api-solutions/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=overflow-api) OverflowAPI Train & fine-tune LLMs (https://stackoverflow.co/labs/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=labs) Labs The future of collective knowledge sharing (https://stackoverflow.co/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=about-the-company) About the company (https://stackoverflow.blog/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=blog) Visit the blog (Search…) () Loading… (https://stackoverflow.com) current community (https://stackoverflow.com) (Stack Overflow) Stack Overflow (https://stackoverflow.com/help) help (https://chat.stackoverflow.com/?tab=site&host=stackoverflow.com) chat (https://meta.stackoverflow.com) (Meta Stack Overflow) Meta Stack Overflow your communities (https://stackoverflow.com/users/signup?ssrc=site_switcher&returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f52277929%2fnginx-408-timeout-reading-client-request-headers) Sign up or (https://stackoverflow.com/users/login?ssrc=site_switcher&returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f52277929%2fnginx-408-timeout-reading-client-request-headers) log in to customize your list. (https://stackexchange.com/sites) more stack exchange communities (https://stackoverflow.blog) company blog (Click to show search) (https://stackoverflow.com/users/login?ssrc=head&returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f52277929%2fnginx-408-timeout-reading-client-request-headers) Log in (https://stackoverflow.com/users/signup?ssrc=head&returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f52277929%2fnginx-408-timeout-reading-client-request-headers) Sign up Let's set up your homepage Select a few topics you're interested in: python javascript c# reactjs java android html flutter c++ node.js typescript css r php angular next.js spring-boot machine-learning sql excel ios azure docker Or search from our full list: (Search) javascript python java c# php android html jquery c++ css ios sql mysql r reactjs node.js arrays c asp.net json python-3.x .net ruby-on-rails sql-server swift django angular objective-c excel pandas angularjs regex typescript ruby linux ajax iphone vba xml laravel spring asp.net-mvc database wordpress string flutter postgresql mongodb wpf windows amazon-web-services xcode bash git oracle-database spring-boot dataframe azure firebase list multithreading docker vb.net react-native eclipse algorithm powershell macos visual-studio numpy image forms scala function vue.js performance twitter-bootstrap selenium winforms kotlin loops express dart hibernate sqlite matlab python-2.7 shell rest apache entity-framework android-studio csv api maven linq qt dictionary unit-testing facebook asp.net-core tensorflow apache-spark file swing class unity-game-engine sorting date authentication go symfony opencv t-sql matplotlib .htaccess google-chrome for-loop datetime codeigniter http perl validation sockets google-maps object uitableview xaml oop if-statement visual-studio-code cordova ubuntu web-services email android-layout github elasticsearch spring-mvc kubernetes selenium-webdriver ms-access user-interface parsing ggplot2 pointers machine-learning c++11 security google-sheets flask google-apps-script ruby-on-rails-3 nginx templates variables exception sql-server-2008 gradle debugging tkinter listview delphi jpa asynchronous pdf web-scraping haskell jsp ssl amazon-s3 google-cloud-platform jenkins testing xamarin wcf npm batch-file generics ionic-framework network-programming unix recursion google-app-engine mongoose visual-studio-2010 .net-core android-fragments assembly animation math next.js session svg hadoop intellij-idea curl django-models join laravel-5 winapi rust url heroku http-redirect tomcat google-cloud-firestore inheritance webpack keras image-processing asp.net-mvc-4 gcc web logging dom swiftui matrix pyspark actionscript-3 button post optimization firebase-realtime-database jquery-ui iis cocoa xpath d3.js firefox javafx internet-explorer xslt caching select asp.net-mvc-3 opengl events asp.net-web-api plot dplyr magento encryption search stored-procedures amazon-ec2 ruby-on-rails-4 memory audio canvas multidimensional-array jsf random cookies vector redux facebook-graph-api input flash xamarin.forms indexing arraylist ipad cocoa-touch data-structures video apache-kafka model-view-controller serialization jdbc woocommerce routes razor awk azure-devops servlets mod-rewrite beautifulsoup docker-compose iframe filter excel-formula aws-lambda design-patterns text django-rest-framework visual-c++ cakephp mobile android-intent react-hooks struct methods groovy mvvm ssh lambda checkbox google-chrome-extension ecmascript-6 time installation grails sharepoint cmake spring-security shiny jakarta-ee android-recyclerview plsql core-data types meteor android-activity sed websocket bootstrap-4 activerecord graph replace scikit-learn file-upload group-by vim junit deep-learning boost import sass memory-management error-handling async-await eloquent dynamic soap silverlight dependency-injection charts layout apache-spark-sql deployment browser gridview svn while-loop google-bigquery vuejs2 ffmpeg dll highcharts view foreach plugins c#-4.0 makefile redis reporting-services jupyter-notebook server merge https unicode reflection google-maps-api-3 twitter oauth-2.0 extjs pytorch axios terminal pip split mysqli cmd encoding django-views automation database-design netbeans collections hash build data-binding ember.js tcp sqlalchemy pdo apache-flex concurrency command-line spring-data-jpa entity-framework-core printing java-8 react-redux jestjs service html-table neo4j ansible lua parameters material-ui module visual-studio-2012 enums promise flexbox outlook webview firebase-authentication web-applications uwp jquery-mobile utf-8 datatable python-requests parallel-processing drop-down-menu colors scroll hive tfs scipy count syntax ms-word twitter-bootstrap-3 ssis google-analytics three.js fonts graphql powerbi constructor rxjs file-io paypal discord cassandra socket.io graphics compiler-errors gwt react-router nlp solr backbone.js url-rewriting datatables memory-leaks oauth datagridview drupal terraform oracle11g zend-framework neural-network knockout.js django-forms triggers interface google-api angular-material casting jmeter linked-list proxy path timer django-templates arduino orm directory parse-platform cron visual-studio-2015 windows-phone-7 push-notification conditional-statements primefaces functional-programming pagination model jar xamarin.android hyperlink uiview visual-studio-2013 gitlab vbscript google-cloud-functions azure-active-directory jwt download swift3 sql-server-2005 process configuration rspec properties pygame combobox callback windows-phone-8 safari linux-kernel permissions scrapy raspberry-pi scripting emacs clojure scope io x86 compilation mongodb-query responsive-design nhibernate angularjs-directive request expo bluetooth 3d dns binding azure-functions reference discord.js architecture playframework pyqt version-control doctrine-orm package pycharm get sql-server-2012 rubygems f# autocomplete datepicker openssl kendo-ui tree jackson controller yii nested grep xamarin.ios static statistics dockerfile transactions null datagrid active-directory uiviewcontroller phpmyadmin webforms discord.py notifications computer-vision sas duplicates mocking youtube nullpointerexception yaml menu sum bitmap electron asp.net-mvc-5 visual-studio-2008 time-series yii2 jsf-2 css-selectors android-listview stl blazor floating-point cryptography ant stream hashmap character-encoding msbuild sdk asp.net-core-mvc google-drive-api selenium-chromedriver jboss joomla navigation cors devise anaconda frontend background camera pyqt5 multiprocessing binary cuda linq-to-sql iterator mariadb onclick ios7 plotly rabbitmq android-asynctask android-jetpack-compose microsoft-graph-api tabs laravel-4 insert amazon-dynamodb uicollectionview environment-variables linker console xsd coldfusion upload continuous-integration ftp textview opengl-es operating-system mockito vuejs3 localization xml-parsing macros formatting json.net kivy type-conversion data.table timestamp calendar integer segmentation-fault android-ndk drag-and-drop prolog char crash jasmine automated-tests dependencies geometry android-gradle-plugin itext firebase-cloud-messaging header sprite-kit mfc fortran attributes nosql nuxt.js format nestjs azure-pipelines odoo jquery-plugins db2 leaflet jenkins-pipeline postman event-handling flutter-layout annotations julia keyboard textbox arm visual-studio-2017 gulp libgdx stripe-payments xampp synchronization crystal-reports timezone azure-web-app-service android-emulator dom-events swagger uikit wso2 sequelize.js aggregation-framework namespaces uiscrollview jvm chart.js google-sheets-formula com subprocess geolocation centos webdriver html5-canvas widget dialog garbage-collection numbers concatenation snowflake-cloud-data-platform sql-update qml windows-10 set mapreduce smtp tuples ionic2 java-stream rotation modal-dialog android-edittext spring-data http-headers radio-button nuget doctrine grid sonarqube lucene xmlhttprequest internationalization listbox components initialization switch-statement google-play boolean apache-camel serial-port ldap ios5 youtube-api return gdb latex pivot eclipse-plugin frameworks tags containers dataset github-actions asp-classic foreign-keys subquery label copy uinavigationcontroller google-cloud-storage delegates c++17 struts2 migration base64 protractor queue sql-server-2008-r2 find uibutton embedded arguments composer-php append jaxb zip stack cucumber autolayout ide popup entity-framework-6 iteration windows-7 airflow r-markdown ssl-certificate vb6 gmail jqgrid hover udp g++ tailwind-css Next You’ll be prompted to create an account to view your personalized homepage. (/) Home (/questions) Questions (/tags) Tags (/users) Users (https://stackoverflow.com/jobs/companies?so_medium=stackoverflow&so_source=SiteNav) Companies Labs (/jobs?source=so-left-nav) Jobs (/beta/discussions) Discussions Collectives Communities for your favorite technologies. (/collectives-all) Explore all Collectives Teams () Ask questions, find answers and collaborate at work with Stack Overflow for Teams. (https://stackoverflowteams.com/teams/create/free/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=side-bar&utm_content=explore-teams) Try Teams for free (https://stackoverflow.co/teams/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=side-bar&utm_content=explore-teams) Explore Teams Teams Ask questions, find answers and collaborate at work with Stack Overflow for Teams. (https://stackoverflow.co/teams/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=side-bar&utm_content=explore-teams-compact) Explore Teams Collectives™ on Stack Overflow Find centralized, trusted content and collaborate around the technologies you use most. (/collectives) Learn more about Collectives Teams Q&A for work Connect and share knowledge within a single location that is structured and easy to search. (https://stackoverflow.co/teams/) Learn more about Teams Get early access and see previews of new features. (https://stackoverflow.co/labs/) Learn more about Labs (https://cdn.sstatic.net/Sites/stackoverflow/Img/apple-touch-icon.png?v=c78bd457575a) (/questions/52277929/nginx-408-timeout-reading-client-request-headers) NGINX 408 timeout (reading client request headers) (/questions/ask) Ask Question (2018-09-11 14:12:01Z) Asked 6 years, 5 months ago Modified (?lastactivity) (2024-07-15 06:01:40Z) 7 months ago (Viewed 17,082 times) Viewed 17k times This question shows research effort; it is useful and clear (70:3:31e,16:dbb636fbbca2db6a,10:1740036919,16:343b2a0140acd777,8:52277929,dde427fdc90599ee05e325474b61f6a113cb094c951d7ecba8986d348b489a66) 4 (This question does not show any research effort; it is unclear or not useful) (70:3:31e,16:3f2cc5d8c8ae1607,10:1740036919,16:e0500d3d59922ca2,8:52277929,1630b5602292ae6f1075dc5ba15707c1d33ceba40304c09490a4a0329272552d) Save this question. (/posts/52277929/timeline) Show activity on this post. I'm working on a server that is receiving requests from IoT devices. They perform a HEAD request on boot. Unfortunately, it seems there's something wrong with the headers. NGINX access log [11/Sep/2018:13:41:11 +0000] "HEAD / HTTP/1.1" 408 0 "-" "-" --- "-" "-" The log format is as follows log_format custom '[$time_local] "$request" $status $body_bytes_sent ' '"$http_referer" "$http_user_agent" ---' '"$content_type" "$content_length"'; NGINX error log 2018/09/11 13:40:11 [debug] 31368#31368: *1 accept: SRCIP:33930 fd:32 2018/09/11 13:40:11 [debug] 31368#31368: *1 event timer add: 32: 60000:1536673271229 2018/09/11 13:40:11 [debug] 31368#31368: *1 reusable connection: 1 2018/09/11 13:40:11 [debug] 31368#31368: *1 epoll add event: fd:32 op:1 ev:80002001 2018/09/11 13:40:11 [debug] 31368#31368: *1 post event 000056011DBAA2C0 2018/09/11 13:40:11 [debug] 31368#31368: *1 delete posted event 000056011DBAA2C0 2018/09/11 13:40:11 [debug] 31368#31368: *1 http wait request handler 2018/09/11 13:40:11 [debug] 31368#31368: *1 malloc: 000056011DAAB650:1024 2018/09/11 13:40:11 [debug] 31368#31368: *1 recv: fd:32 71 of 1024 2018/09/11 13:40:11 [debug] 31368#31368: *1 reusable connection: 0 2018/09/11 13:40:11 [debug] 31368#31368: *1 posix_memalign: 000056011DB0DCD0:4096 @16 2018/09/11 13:40:11 [debug] 31368#31368: *1 http process request line 2018/09/11 13:40:11 [debug] 31368#31368: *1 http request line: "HEAD / HTTP/1.1" 2018/09/11 13:40:11 [debug] 31368#31368: *1 http uri: "/" 2018/09/11 13:40:11 [debug] 31368#31368: *1 http args: "" 2018/09/11 13:40:11 [debug] 31368#31368: *1 http exten: "" 2018/09/11 13:40:11 [debug] 31368#31368: *1 posix_memalign: 000056011DB690C0:4096 @16 2018/09/11 13:40:11 [debug] 31368#31368: *1 http process request header line 2018/09/11 13:40:11 [debug] 31368#31368: *1 http header: "Host: MYHOST" 2018/09/11 13:40:11 [debug] 31368#31368: *1 recv: fd:32 -1 of 953 2018/09/11 13:40:11 [debug] 31368#31368: *1 recv() not ready (11: Resource temporarily unavailable) 2018/09/11 13:41:11 [debug] 31368#31368: *1 event timer del: 32: 1536673271229 2018/09/11 13:41:11 [debug] 31368#31368: *1 http process request header line 2018/09/11 13:41:11 [info] 31368#31368: *1 client timed out (110: Connection timed out) while reading client request headers, client: SRCIP, server: MYHOST, request: "HEAD / HTTP/1.1", host: "MYHOST" 2018/09/11 13:41:11 [debug] 31368#31368: *1 http request count:1 blk:0 2018/09/11 13:41:11 [debug] 31368#31368: *1 http close request 2018/09/11 13:41:11 [debug] 31368#31368: *1 http log handler 2018/09/11 13:41:11 [debug] 31368#31368: *1 free: 000056011DB0DCD0, unused: 707 2018/09/11 13:41:11 [debug] 31368#31368: *1 free: 000056011DB690C0, unused: 3104 2018/09/11 13:41:11 [debug] 31368#31368: *1 close http connection: 32 2018/09/11 13:41:11 [debug] 31368#31368: *1 reusable connection: 0 2018/09/11 13:41:11 [debug] 31368#31368: *1 free: 000056011DAAB650 2018/09/11 13:41:11 [debug] 31368#31368: *1 free: 000056011DAFF960, unused: 128 Tcpdump sudo tcpdump -n -S -s 0 -A 'src SRCIP and port 80' shows 13:55:32.846408 IP SRCIP.39761 > DSTIP.80: Flags [S], seq 1846787, win 2920, options [mss 1460], length 0 E..,....p. *E......h.Q.P........`..h\;........ 13:55:33.153456 IP SRCIP.39761 > DSTIP.80: Flags [.], ack 3538300854, win 2920, length 0 E..(....p..^E......h.Q.P....../.P..hqK........ 13:55:33.314206 IP SRCIP.39761 > DSTIP.80: Flags [P.], seq 1846788:1846859, ack 3538300854, win 2920, length 71: HTTP: HEAD / HTTP/1.1 E..o&...p..CE......h.Q.P....../.P..hg...HEAD / HTTP/1.1 Host: MYHOST Content-Length: 13:56:33.363048 IP SRCIP.39761 > DSTIP.80: Flags [F.], seq 1846859, ack 3538300855, win 2919, length 0 E..(....p...E......h.Q.P...K../.P..gq......... I cannot change the firmware in the devices so I'm looking for a workaround on the NGINX side. Please let me know if I can provide more info to help with the answer. EDIT: I'm not adding the server config because I've tried too many and I'm not sure what to paste here. EDIT 2: tcpdump at first logs 13:55:32.846408 IP SRCIP.39761 > DSTIP.80: Flags [S], seq 1846787, win 2920, options [mss 1460], length 0 E..,....p. *E......h.Q.P........`..h\;........ 13:55:33.153456 IP SRCIP.39761 > DSTIP.80: Flags [.], ack 3538300854, win 2920, length 0 E..(....p..^E......h.Q.P....../.P..hqK........ 13:55:33.314206 IP SRCIP.39761 > DSTIP.80: Flags [P.], seq 1846788:1846859, ack 3538300854, win 2920, length 71: HTTP: HEAD / HTTP/1.1 E..o&...p..CE......h.Q.P....../.P..hg...HEAD / HTTP/1.1 Host: MYHOST Content-Length: And then the rest after some time. I assume it's after NGINX times out. EDIT 3: I finally understand what's going on. This has been really confusing because there's one Apache server in production with which the devices work properly. While trying to switch to NGINX things stopped working. As I've said above, the IoT devices on boot are performing a HEAD request. They expect a response with a Date: header so that they can parse it. Currently, the device are working fine with Apache because when a timeout is triggered while waiting for headers from the client, Apache returns a 408 response to the client, including the Date: header. This directive can set various timeouts for receiving the request headers and the request body from the client. If the client fails to send headers or body within the configured time, a 408 REQUEST TIME OUT error is sent. ((https://httpd.apache.org/docs/2.4/mod/mod_reqtimeout.html) https://httpd.apache.org/docs/2.4/mod/mod_reqtimeout.html ) On the other hand, NGINX when a when a timeout is triggered while waiting for headers from the client, just closes the connection without returning anything to the client. Even if it logs 408 in the access log. Defines a timeout for reading client request header. If a client does not transmit the entire header within this time, the request is terminated with the 408 (Request Time-out) error. ((http://nginx.org/en/docs/http/ngx_http_core_module.html#client_header_timeout) http://nginx.org/en/docs/http/ngx_http_core_module.html#client_header_timeout ) There's been a discussion on this behaviour already (https://trac.nginx.org/nginx/ticket/1005) https://trac.nginx.org/nginx/ticket/1005 . In other words, the HEAD request from the IoT devices has always being wrong. It just works with Apache because a 408 response with Date: is sent back whenever a timeout while waiting for headers is triggered. As I said above, unfortunately there's no way for me to change how the devices work. Thus, I need to workaround in NGINX. The only way I found is to change the source and compile myself. This is what I came up with by copy / pasting from the internet. Unfortunately, I haven't had time to understand the code and prolly won't ever. It would be really great if somebody helped me understanding how bad that code is and what's a better way of writing it. The version of NGINX is 1.14.0. diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c index 2db7a62..086701b 100644 --- a/src/http/ngx_http_request.c +++ b/src/http/ngx_http_request.c @@ -1236,7 +1236,7 @@ ngx_http_process_request_headers(ngx_event_t *rev) if (rev->timedout) { ngx_log_error(NGX_LOG_INFO, c->log, NGX_ETIMEDOUT, "client timed out"); c->timedout = 1; - ngx_http_close_request(r, NGX_HTTP_REQUEST_TIME_OUT); + ngx_http_finalize_request(r, ngx_http_special_response_handler(r, NGX_HTTP_REQUEST_TIME_OUT)); return; } To validate the code is working I used Telnet: This is what NGINX normally would do Request $ telnet HOST 80 Trying IP... Connected to HOST. Escape character is '^]'. HEAD / HTTP/1.1 Content-Length: Response Connection closed by foreign host. This is what NGINX does with the modified code Request $ telnet HOST 80 Trying IP... Connected to HOST. Escape character is '^]'. HEAD / HTTP/1.1 Content-Length: Response HTTP/1.1 408 Request Time-out Server: nginx Date: Tue, 25 Sep 2018 08:18:41 GMT Content-Type: text/html Content-Length: 176 Connection: close Notice that I could use another header in place of Content-Length: (e.g. Accept: and the result would be the same). If you are trying to reproduce just remember to press enter once (and only once) after the empty header (in the example Content-Length: ). (/questions/tagged/nginx) (show questions tagged 'nginx') nginx (/q/52277929) (Short permalink to this question) Share Share a link to this question Copy link (https://creativecommons.org/licenses/by-sa/4.0/) (The current license for this post: CC BY-SA 4.0) CC BY-SA 4.0 (/posts/52277929/edit) () Improve this question Follow (70:3:31e,16:f6c43105cee0572c,10:1740036919,16:8bc864dc21f87725,8:52277929,bb7eb629eed192894413778973c87f7a1e4f12a11c00e83dd025e900c56fe9e5) Follow this question to receive notifications (/posts/52277929/revisions) (show all edits to this post) edited (2018-09-25 08:27:59Z) Sep 25, 2018 at 8:27 3v0k4 asked (2018-09-11 14:12:01Z) Sep 11, 2018 at 14:12 (/users/2700809/3v0k4) (3v0k4's user avatar) (/users/2700809/3v0k4) 3v0k4 3v0k4 (reputation score) 161 (1 gold badge) 1 1 gold badge (4 silver badges) 4 4 silver badges (10 bronze badges) 10 10 bronze badges 6 It looks like they never send value for the Content-Length header, and they don't send the "blank line " after the headers either... How is the server supposed to know that the client has finished sending the headers? – (/users/1347519/attie) (6,979 reputation) Attie Commented (2018-09-11 14:26:45Z, License: CC BY-SA 4.0) Sep 11, 2018 at 14:26 Do you have control of the Content-Length value or the content? If so, is it expected to include a newline, but is currently empty? – (/users/1347519/attie) (6,979 reputation) Attie Commented (2018-09-11 14:27:31Z, License: CC BY-SA 4.0) Sep 11, 2018 at 14:27 What are the devices? – (/users/1347519/attie) (6,979 reputation) Attie Commented (2018-09-11 14:27:40Z, License: CC BY-SA 4.0) Sep 11, 2018 at 14:27 Sensors with a custom firmware. Unfortunately, there's no way for me to change the code in the sensors. I need to find a workaround in NGINX. – (/users/2700809/3v0k4) (161 reputation) 3v0k4 Commented (2018-09-11 14:35:36Z, License: CC BY-SA 4.0) Sep 11, 2018 at 14:35 I'm not totally sure what's going on. One thing I forgot to mention is that tcpdump stops at Content-Length: for some time. I assume it's because NGINX is waiting for data but the sensor does not send anything. – (/users/2700809/3v0k4) (161 reputation) 3v0k4 Commented (2018-09-11 14:38:11Z, License: CC BY-SA 4.0) Sep 11, 2018 at 14:38 (Use comments to ask for more information or suggest improvements. Avoid answering questions in comments.) | (Expand to show all comments on this post) Show 1 more comment 2 Answers 2 Sorted by: (/questions/52277929/nginx-408-timeout-reading-client-request-headers?answertab=scoredesc#tab-top) Reset to default (scoredesc) Highest score (default) (trending) Trending (recent votes count more) (modifieddesc) Date modified (newest first) (createdasc) Date created (oldest first) This answer is useful (70:3:31e,16:c25afbaf0b985922,10:1740036919,16:66a9f3076e4a05c1,8:52566534,634beeaa942404a5062338b67d90d6c01c6dc98c4cea6da7808cf0d147283d11) -1 (This answer is not useful) (70:3:31e,16:0210c7f70584153b,10:1740036919,16:3dd80e6d867f5ad9,8:52566534,1c094fa59fa3254311c526a1fdf831ccd5e0a59c59affdf84d66b60fc7f41628) Save this answer. (Loading when this answer was accepted…) (/posts/52566534/timeline) Show activity on this post. I ended up using Apache. In fact, it seems like there's no way to configure NGINX to send back the 408 to the client (and not just closing the connection). Patching the source is risky and makes updating the server painful. (/a/52566534) (Short permalink to this answer) Share Share a link to this answer Copy link (https://creativecommons.org/licenses/by-sa/4.0/) (The current license for this post: CC BY-SA 4.0) CC BY-SA 4.0 (/posts/52566534/edit) () Improve this answer Follow (70:3:31e,16:67c6f600c5cddc0d,10:1740036919,16:e7299b783134d0b2,8:52566534,baed3eee6ff5e29c57404d290f3c1d06812367b27156cd20804201f3c5785e7d) Follow this answer to receive notifications (/posts/52566534/revisions) (show all edits to this post) edited (2018-10-04 14:29:31Z) Oct 4, 2018 at 14:29 answered (2018-09-29 08:19:28Z) Sep 29, 2018 at 8:19 (/users/2700809/3v0k4) (3v0k4's user avatar) (/users/2700809/3v0k4) 3v0k4 3v0k4 (reputation score) 161 (1 gold badge) 1 1 gold badge (4 silver badges) 4 4 silver badges (10 bronze badges) 10 10 bronze badges (Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”.) Add a comment | (Expand to show all comments on this post) This answer is useful (70:3:31e,16:1d0cbe3bce53b934,10:1740036919,16:cc3b3d0596128094,8:71178550,11e36d7c081d72670bb3dee046ba3db9674551dc5859eea862ad0dc33f7b56ec) -1 (This answer is not useful) (70:3:31e,16:414cf625fb581fe8,10:1740036919,16:f527dd492b8bb208,8:71178550,fd87795af9742c5ec9a1e2a0ead29070e540db2dd4ec00f8e023dbed0889d3ab) Save this answer. (Loading when this answer was accepted…) (/posts/71178550/timeline) Show activity on this post. I was running into this with a proxy_pass. Originally I had the following configuration: location / { proxy_read_timeout 300s; proxy_connect_timeout 75s; proxy_pass https://internal:3210/; add_header Access-Control-Allow-Origin *; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_buffering off; } Then I commented out the proxy settings and it started to work for me: location / { proxy_read_timeout 300s; proxy_connect_timeout 75s; proxy_pass https://internal:3210/; # add_header Access-Control-Allow-Origin *; # proxy_http_version 1.1; # proxy_set_header Upgrade $http_upgrade; # proxy_set_header Connection "upgrade"; # proxy_buffering off; } (/a/71178550) (Short permalink to this answer) Share Share a link to this answer Copy link (https://creativecommons.org/licenses/by-sa/4.0/) (The current license for this post: CC BY-SA 4.0) CC BY-SA 4.0 (/posts/71178550/edit) () Improve this answer Follow (70:3:31e,16:7e9d121a54420b64,10:1740036919,16:1c74ad0b8a1569b3,8:71178550,da0eed4c16914b22ff258b09a0634927e8de8d71a0fb238733f951a7da25dea1) Follow this answer to receive notifications answered (2022-02-18 18:55:37Z) Feb 18, 2022 at 18:55 (/users/1837496/charles-brandt) (Charles Brandt's user avatar) (/users/1837496/charles-brandt) Charles Brandt Charles Brandt (reputation score) 1,087 (11 silver badges) 11 11 silver badges (13 bronze badges) 13 13 bronze badges (Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”.) Add a comment | (Expand to show all comments on this post) (52277929) (false) () Your Answer (False) Reminder: Answers generated by artificial intelligence tools are not allowed on Stack Overflow. (/help/gen-ai-policy) Learn more (true) Thanks for contributing an answer to Stack Overflow! Please be sure to answer the question . Provide details and share your research! But avoid … Asking for help, clarification, or responding to other answers. Making statements based on opinion; back them up with references or personal experience. To learn more, see our (/help/how-to-answer) tips on writing great answers . Draft saved Draft discarded (8715abeb62cf6a9fe93de824cea527599cbf4e957f73c9d6615a4213f6b2728c) Sign up or (/users/login?ssrc=question_page&returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f52277929%2fnginx-408-timeout-reading-client-request-headers%23new-answer) log in Sign up using Google Sign up using Email and Password (false) (false) Submit Post as a guest Name () () Email Required, but never shown () () Post as a guest Name () () Email Required, but never shown () () Post Your Answer Discard By clicking “Post Your Answer”, you agree to our (https://stackoverflow.com/legal/terms-of-service/public) terms of service and acknowledge you have read our (https://stackoverflow.com/legal/privacy-policy) privacy policy .(1) Not the answer you're looking for? Browse other questions tagged (/questions/tagged/nginx) (show questions tagged 'nginx') nginx or (/questions/ask) ask your own question . The Overflow Blog (https://stackoverflow.blog/2025/02/18/why-is-it-so-hard-for-companies-to-protect-your-privacy/?cb=1) Why is it so hard for companies to protect your privacy? Featured on Meta (Meta Stack Exchange) (https://meta.stackexchange.com/questions/406399/join-us-for-our-first-community-wide-ama-ask-me-anything-with-stack-overflow-s?cb=1) (Join us for our first community-wide AMA (Ask Me Anything) with Stack Overflow’s CEO (and a few others) on February 26, 2025) Join us for our first community-wide AMA (Ask Me Anything) with Stack... (Meta Stack Exchange) (https://meta.stackexchange.com/questions/406575/bigbird-and-frog-have-joined-us-as-community-managers?cb=1) bigbird and Frog have joined us as Community Managers (Meta Stack Overflow) (https://meta.stackoverflow.com/questions/433034/stacks-editor-development-and-testing?cb=1) Stacks Editor development and testing (Meta Stack Overflow) (https://meta.stackoverflow.com/questions/432989/is-it-better-to-redirect-users-who-attempt-to-perform-actions-they-cant-yet-tak?cb=1) (Is it better to redirect users who attempt to perform actions they can't yet take?) Is it better to redirect users who attempt to perform actions they can't yet... (Meta Stack Overflow) (https://meta.stackoverflow.com/questions/421831/policy-generative-ai-e-g-chatgpt-is-banned?cb=1) Policy: Generative AI (e.g., ChatGPT) is banned (https://chat.stackoverflow.com/) Visit chat Related (https://stackoverflow.com/q/1667720?rq=3) (Question score (upvotes - downvotes)) 22 (https://stackoverflow.com/questions/1667720/http-408-request-timeout?rq=3) HTTP 408 Request timeout (https://stackoverflow.com/q/10806928?rq=3) (Question score (upvotes - downvotes)) 90 (https://stackoverflow.com/questions/10806928/increasing-504-timeout-error?rq=3) Increasing 504 timeout error (https://stackoverflow.com/q/12315832?rq=3) (Question score (upvotes - downvotes)) 56 (https://stackoverflow.com/questions/12315832/how-to-fix-nginx-throws-400-bad-request-headers-on-any-header-testing-tools?rq=3) How to fix nginx throws 400 bad request headers on any header testing tools? (https://stackoverflow.com/q/18740635?rq=3) (Question score (upvotes - downvotes)) 249 (https://stackoverflow.com/questions/18740635/nginx-upstream-timed-out-110-connection-timed-out-while-reading-response-hea?rq=3) NGINX: upstream timed out (110: Connection timed out) while reading response header from upstream (https://stackoverflow.com/q/22869677?rq=3) (Question score (upvotes - downvotes)) 0 (https://stackoverflow.com/questions/22869677/why-nginx-is-returning-error-504-timeout-even-if-in-my-nginx-conf-all-the-proper?rq=3) Why nginx is returning error 504 timeout even if in my nginx.conf all the properties are setted (https://stackoverflow.com/q/26441459?rq=3) (Question score (upvotes - downvotes)) 6 (https://stackoverflow.com/questions/26441459/nginx-502-error-and-504-error?rq=3) nginx 502 error and 504 error (https://stackoverflow.com/q/30434235?rq=3) (Question score (upvotes - downvotes)) 2 (https://stackoverflow.com/questions/30434235/a-lot-of-408-on-nginx-due-to-client-body-timeout?rq=3) A lot of 408 on nginx due to client body timeout (https://stackoverflow.com/q/36144520?rq=3) (Question score (upvotes - downvotes)) 0 (https://stackoverflow.com/questions/36144520/avoid-getting-504-response-from-nginx?rq=3) avoid getting 504 response from NGINX (https://stackoverflow.com/q/38650111?rq=3) (Question score (upvotes - downvotes)) 13 (https://stackoverflow.com/questions/38650111/http-request-timeout-at-2-minutes-in-nginx-502-bad-gateway-in-node-app?rq=3) Http request timeout at 2 minutes in NGINX 502 bad gateway in Node app (https://stackoverflow.com/q/62595175?rq=3) (Question score (upvotes - downvotes)) 3 (https://stackoverflow.com/questions/62595175/getting-504-timeout-error-in-a-grpc-call-under-nginx-web-server?rq=3) Getting 504 timeout error in a GRPC call under Nginx web server (https://stackexchange.com/questions?tab=hot) Hot Network Questions (Data Science Stack Exchange) (https://datascience.stackexchange.com/questions/131411/why-my-program-does-not-work-for-higher-dimension-tensors) Why my program does not work for higher dimension tensors? (Vi and Vim Stack Exchange) (https://vi.stackexchange.com/questions/46475/neovim-go-into-insert-mode-and-first-empty-line-in-mutt) Neovim -- go into insert mode and first empty line in mutt (TeX - LaTeX Stack Exchange) (https://tex.stackexchange.com/questions/737460/replace-a-character-in-math-block-within-an-environment) Replace a character in math block within an environment (TeX - LaTeX Stack Exchange) (https://tex.stackexchange.com/questions/737476/align-uncertainty-and-exponant-in-an-s-column-using-siunitx) Align uncertainty and exponant in an `S` column using `siunitx` (Mathematics Educators Stack Exchange) (https://matheducators.stackexchange.com/questions/28465/translating-intuition-into-rigor-motivating-the-proof-of-a-result-from-topologi) Translating Intuition Into Rigor: Motivating The Proof Of A Result From Topological Vector Spaces (Science Fiction & Fantasy Stack Exchange) (https://scifi.stackexchange.com/questions/295034/does-gasoline-propel-the-delorean-to-88-mph-after-the-hover-conversion) Does gasoline propel the DeLorean to 88 mph after the hover conversion? (Arqade) (https://gaming.stackexchange.com/questions/411212/what-are-the-differences-between-borderlands-goty-edition-and-goty-enhanced) What are the differences between Borderlands GOTY Edition and GOTY Enhanced? (Puzzling Stack Exchange) (https://puzzling.stackexchange.com/questions/130588/an-inspiring-game-get-it) An inspiring game, get it? (Academia Stack Exchange) (https://academia.stackexchange.com/questions/216881/do-universities-allow-researchers-to-allocate-a-portion-of-their-working-time-to) Do universities allow researchers to allocate a portion of their working time to professional development? (Stack Overflow) (https://stackoverflow.com/questions/79452303/why-does-throwing-an-error-in-a-not-yet-awaited-async-function-call-terminate-no) Why does throwing an error in a not-yet-awaited async function call terminate node.js? (Law Stack Exchange) (https://law.stackexchange.com/questions/107440/how-does-the-federal-government-have-jurisdiction-to-charge-luigi-mangione) How does the Federal government have jurisdiction to charge Luigi Mangione? (Mathematics Stack Exchange) (https://math.stackexchange.com/questions/5036980/question-about-4-points-on-the-same-circle) Question about 4 points on the same circle (Blender Stack Exchange) (https://blender.stackexchange.com/questions/331396/trouble-aligning-array-modifier) Trouble Aligning Array Modifier (Database Administrators Stack Exchange) (https://dba.stackexchange.com/questions/345345/how-can-i-make-queries-on-a-dynamic-part-of-my-data-fast) How can I make queries on a dynamic part of my data fast? (Worldbuilding Stack Exchange) (https://worldbuilding.stackexchange.com/questions/264756/using-telekinesis-for-workouts-without-actually-doing-workouts) Using telekinesis for workouts without actually doing workouts? (Philosophy Stack Exchange) (https://philosophy.stackexchange.com/questions/122848/if-our-memory-fails-how-can-we-be-sure-of-what-we-know) If our memory fails, how can we be sure of what we know? (Politics Stack Exchange) (https://politics.stackexchange.com/questions/90656/what-was-the-source-of-the-feb-18-2025-statement-president-zelensky-only-has-a) What was the source of the Feb 18, 2025 statement President Zelensky only has a 4% approval rating? (Law Stack Exchange) (https://law.stackexchange.com/questions/107429/are-the-ballots-in-the-american-congress-anonymous) Are the ballots in the American Congress anonymous? (Puzzling Stack Exchange) (https://puzzling.stackexchange.com/questions/130593/missing-letters-should-have-received-more) Missing letters (should have received more) (Board & Card Games Stack Exchange) (https://boardgames.stackexchange.com/questions/61766/how-does-single-combat-handle-creatures-that-cant-be-sacrificed) How does Single Combat handle creatures that can't be sacrificed? (Physics Stack Exchange) (https://physics.stackexchange.com/questions/843330/who-exerts-force-on-whom) Who exerts force on whom? (Retrocomputing Stack Exchange) (https://retrocomputing.stackexchange.com/questions/31303/can-someone-identify-the-hardware-in-the-movie-hard-car) Can someone identify the hardware in the movie "Hard Car"? (Academia Stack Exchange) (https://academia.stackexchange.com/questions/216904/politely-asking-a-pi-to-hurry-up-with-admission-decisions-because-i-have-another) Politely asking a PI to hurry up with admission decisions because I have another offer (Puzzling Stack Exchange) (https://puzzling.stackexchange.com/questions/130567/prove-that-the-equality-1-a-1-b-1-c-1-d-1-e-1-f-1-has-no-solutions-i) Prove that the equality, 1/a+ 1/b + 1/c + 1/d + 1/e + 1/f = 1 has no solutions in odd natural numbers (/feeds/question/52277929) (Feed of this question and its answers) Question feed Subscribe to RSS Question feed To subscribe to this RSS feed, copy and paste this URL into your RSS reader. (https://stackoverflow.com/feeds/question/52277929) () (https://stackoverflow.com) (https://stackoverflow.com) Stack Overflow (/questions) Questions (/help) Help (https://chat.stackoverflow.com/?tab=site&host=stackoverflow.com) Chat (https://stackoverflow.co/) Products (https://stackoverflow.co/teams/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=footer&utm_content=teams) Teams (https://stackoverflow.co/advertising/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=footer&utm_content=advertising) Advertising (https://stackoverflow.co/advertising/employer-branding/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=footer&utm_content=talent) Talent (https://stackoverflow.co/) Company (https://stackoverflow.co/) About (https://stackoverflow.co/company/press/) Press (https://stackoverflow.co/company/work-here/) Work Here (https://stackoverflow.com/legal) Legal (https://stackoverflow.com/legal/privacy-policy) Privacy Policy (https://stackoverflow.com/legal/terms-of-service/public) Terms of Service (/contact) Contact Us Cookie Settings (https://stackoverflow.com/legal/cookie-policy) Cookie Policy (https://stackexchange.com) Stack Exchange Network (https://stackexchange.com/sites#technology) Technology (https://stackexchange.com/sites#culturerecreation) Culture & recreation (https://stackexchange.com/sites#lifearts) Life & arts (https://stackexchange.com/sites#science) Science (https://stackexchange.com/sites#professional) Professional (https://stackexchange.com/sites#business) Business (https://api.stackexchange.com/) API (https://data.stackexchange.com/) Data (https://stackoverflow.blog?blb=1) Blog (https://www.facebook.com/officialstackoverflow/) Facebook (https://twitter.com/stackoverflow) Twitter (https://linkedin.com/company/stack-overflow) LinkedIn (https://www.instagram.com/thestackoverflow) Instagram Site design / logo © 2025 Stack Exchange Inc; user contributions licensed under (https://stackoverflow.com/help/licensing) CC BY-SA . rev 2025.2.19.22863