2019-01-16 22:16:33 8 Comments
I'm having a particularly odd behaviour with my docker-compose and nginx setup. I am trying to have nginx proxy_pass requests to a backend web service. The web service is Spring Boot, but I don't believe that's relevant. My web service will issue a 302 redirect to users who are not authenticated, sending them to a /login page. This all seems to work as expected except for an indeterminate period of time when I bring the docker-compose up. Early requests to the service which result in 302 responses result in timeouts, whilst requests direct to the /login page return as expected immediately. After an indeterminate period of time, usually minutes, something seems to stabilise and everything works as expected. I've verified the behaviour using chrome from a client machine and curl directly on the host running the compose. I believe the 302 responses are somehow getting dropped but I'm not sure.
Can anyone spot a problem?
version: '3.5' services: proxy: image: nginx:latest container_name: "proxy" restart: always volumes: - blah:/etc/nginx ports: - 80:80 - 443:443 webservice: image: "webservice:latest" container_name: "webservice" restart: always ports: - 8080:8080
Nginx Config:
worker_processes auto; events { } http { server { listen 80 default_server; listen 443 default_server ssl; ssl_certificate /etc/nginx/cert; ssl_certificate_key /etc/nginx/key; if ($scheme = http) { return 301 https://$host:443$request_uri; } gzip on; gzip_types text/plain application/xml application/json application/javascript; location / { proxy_http_version 1.1; proxy_pass http://webservice:8080/; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $host:$server_port; 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 $scheme; proxy_set_header X-Forwarded-Port $server_port; access_log /etc/nginx/log/access.log combined; error_log /etc/nginx/log/error.log warn; } } }
Related Questions
Sponsored Content
53 Answered Questions
[SOLVED] How to remove old Docker containers
- 2013-06-21 13:41:42
- qkrijger
- 653656 View
- 1066 Score
- 53 Answer
- Tags: docker
27 Answered Questions
2 Answered Questions
42 Answered Questions
[SOLVED] How to get a Docker container's IP address from the host?
- 2013-06-17 22:10:22
- Murali Allada
- 835392 View
- 964 Score
- 42 Answer
- Tags: docker
58 Answered Questions
[SOLVED] How do I redirect to another webpage?
- 2009-02-02 12:54:16
- venkatachalam
- 5501677 View
- 7733 Score
- 58 Answer
- Tags: javascript jquery redirect
17 Answered Questions
[SOLVED] From inside of a Docker container, how do I connect to the localhost of the machine?
- 2014-06-20 03:54:16
- Phil
- 436630 View
- 829 Score
- 17 Answer
- Tags: nginx docker reverse-proxy docker-networking
34 Answered Questions
[SOLVED] Copying files from host to Docker container
- 2014-04-07 08:28:55
- user3001829
- 811198 View
- 1109 Score
- 34 Answer
- Tags: docker docker-container
10 Answered Questions
19 Answered Questions
[SOLVED] How is Docker different from a virtual machine?
- 2013-04-16 21:19:47
- zslayton
- 629673 View
- 3210 Score
- 19 Answer
- Tags: docker containers virtual-machine virtualization
0 comments