nginx - Multiple upstream proxies failing -
i've been playing around using docker setup group of web applications sit behind nginx container. i'm using docker-compose
manage different services , of individual web service containers work fine when try access them nginx container 1 of them works , it's first 1 try access. if start container group , access app1 page expected if go app2 50x error. if restart group , go app2 first page expected if go app1 50x error now. i'm not sure i'm doing wrong in nginx config. assistance appreciated.
here nginx config:
upstream app1_backend { server app1:8000; } upstream app2_backend { server app2:8000; } server { listen 80 default_server; server_name localhost; charset utf-8; #location / { # root /usr/share/nginx/html; # index index.html index.htm; #} #error_page 404 /404.html; # redirect server error pages static page /50x.html error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } location /static { alias /static; } location /app1/ { proxy_pass http://app1_backend/; proxy_http_version 1.1; proxy_set_header upgrade $http_upgrade; proxy_set_header connection 'upgrade'; proxy_set_header host $host; proxy_cache_bypass $http_upgrade; proxy_set_header x-real-ip $remote_addr; proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for; } location /app2/ { proxy_pass http://app2_backend/; proxy_http_version 1.1; proxy_set_header upgrade $http_upgrade; proxy_set_header connection 'upgrade'; proxy_set_header host $host; proxy_cache_bypass $http_upgrade; proxy_set_header x-real-ip $remote_addr; proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for; } }
and again can access individual applications @ http://app1:8000/
, http://app2:8000/
.
i figured out doing wrong. had server_name localhost;
. changing server_name _;
fixed issue.
Comments
Post a Comment