Created
September 24, 2019 04:55
-
-
Save sivakumarbdu/614203a62a9e03cf189b8aae184720ac to your computer and use it in GitHub Desktop.
Nginx Routing Base based
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
worker_processes 4; | |
events { worker_connections 1024; } | |
http { | |
upstream app1_stream { | |
least_conn; | |
server app1:3000 weight=10 max_fails=3 fail_timeout=30s; | |
} | |
upstream app2_stream { | |
least_conn; | |
server app2:8001 weight=10 max_fails=3 fail_timeout=30s; | |
} | |
upstream app3_stream { | |
server app3:3000; | |
} | |
upstream app4_stream { | |
server app4:8000; | |
} | |
server { | |
listen 80; | |
proxy_set_header X-Forwarded-Proto $scheme; | |
if ( $http_x_forwarded_proto != 'https' ) { | |
return 301 https://$host$request_uri; | |
} | |
location ~* /ap1_url/(.*) { | |
proxy_set_header Host $host; | |
proxy_pass http://app1; | |
} | |
location ~* /app2_url/(.*) { | |
proxy_set_header Host $host; | |
proxy_pass http://app2; | |
} | |
location ~* /app3_url/(.*) { | |
proxy_set_header Host $host; | |
proxy_pass http://app3; | |
} | |
location ~* /assets/(.*) { | |
proxy_set_header Host $host; | |
proxy_pass http://app2_url; | |
} | |
location / { | |
proxy_pass http://app1; | |
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; | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment