question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

nginx timeout : timeout issues

See original GitHub issue

I have having timeout problems with nginx. After looking through the config I see a problem

my docker container was started up with -e VIRTUAL_HOST=foo.bar.com docker ps gives me 971c26986bb3 [snip] 0.0.0.0:49156->3000/tcp my_app docker inspect 971c26986bb3 gives me

“NetworkSettings”: { “Bridge”: “docker0”, “Gateway”: “172.17.42.1”, “GlobalIPv6Address”: “”, “GlobalIPv6PrefixLen”: 0, “IPAddress”: “172.17.0.78”,

curl -H ‘Host: foo.bar.com’ http://localhost gives me a timeout curl -H ‘Host: foo1.bar.com’ http://localhost gives me a 503 Service Temporarily Unavailable (as expected)

curl -H ‘Host: foo.bar.com’ http://localhost:49156 gives me the expected data (so proving that the server is running on 49156->3000)

so, what am I doing wrong ?

# If we receive X-Forwarded-Proto, pass it through; otherwise, pass along the
# scheme used to connect to this server
map $http_x_forwarded_proto $proxy_x_forwarded_proto {
  default $http_x_forwarded_proto;
  ''      $scheme;
}

# If we receive Upgrade, set Connection to "upgrade"; otherwise, delete any
# Connection header that may have been passed to this server
map $http_upgrade $proxy_connection {
  default upgrade;
  ''      '';
}

gzip_types text/plain text/css application/javascript application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

log_format vhost '$host $remote_addr - $remote_user [$time_local] '
                 '"$request" $status $body_bytes_sent '
                 '"$http_referer" "$http_user_agent"';

access_log /proc/self/fd/1 vhost;
error_log /proc/self/fd/2;

# HTTP 1.1 support
proxy_http_version 1.1;
proxy_buffering off;
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $proxy_connection;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $proxy_x_forwarded_proto;

server {
        listen 80 default_server;
        server_name _; # This is just an invalid value which will never trigger on a real hostname.
        return 503;
}

upstream foo.bar.com {
                   # my_app
                   server 172.17.0.78:3000;
}

server {
        server_name foo.bar.com;

        location / {
                proxy_pass http://foo.bar.com;

        }
}

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:13 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
md5commented, Jul 28, 2015

@exadeci What does the Dockerfile in your local directory look like? I suspect it isn’t exposing any ports.

1reaction
exadecicommented, Jul 28, 2015

And…I missed that 😓. I exposed it on the docker-compose and now it works. Thank you

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Fix 504 Gateway Timeout using Nginx - Easy Cloud
It is very common to see a 504 Gateway Timeout error using Nginx webserver. This timeout error is generated often by a number...
Read more >
How to Increase Request Timeout in NGINX - Ubiq BI
By default, NGINX request timeout is 60 seconds. Sometimes you may need to increase request timeout in NGINX to serve long-running requests.
Read more >
Can't change NGINX timeout - Server Fault
The problem is that the data files are only generated when requested. So when complex data is requested the Python backend takes more...
Read more >
Fixing a 504 Gateway Timeout Error - KeyCDN Support
If you use Nginx as a proxy, you need to increase the Nginx timeout values in your nginx.conf file. To do so, add...
Read more >
Nginx reverse proxy causing 504 Gateway Timeout
Increasing the timeout will not likely solve your issue since, as you say, the actual target web server is responding ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found