Last active
September 25, 2019 09:51
-
-
Save sivakumarbdu/b222a8725f5564165d4e40b4c17a93a7 to your computer and use it in GitHub Desktop.
Nginx Domain name based routing
This file contains hidden or 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 { | |
least_conn; | |
server app:3000 weight=10 max_fails=3 fail_timeout=30s; | |
} | |
upstream app2 { | |
least_conn; | |
server api:4000 weight=10 max_fails=3 fail_timeout=30s; | |
} | |
server { | |
listen 80; | |
servername app1.lvh.me | |
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; | |
} | |
} | |
server { | |
listen 80; | |
servername app2.lvh.me | |
location / { | |
proxy_pass http://app2; | |
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