Last active
April 22, 2018 09:54
-
-
Save abhilash1in/2ba4214742b584f49b553d97b7c7f2fe to your computer and use it in GitHub Desktop.
nginx configuration for portainer with multiple websites reverse proxied to different ports based on hostname
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
user nginx; | |
worker_processes 1; | |
error_log /var/log/nginx/error.log warn; | |
pid /var/run/nginx.pid; | |
events { | |
worker_connections 1024; | |
} | |
http { | |
include /etc/nginx/mime.types; | |
default_type application/octet-stream; | |
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' | |
'$status $body_bytes_sent "$http_referer" ' | |
'"$http_user_agent" "$http_x_forwarded_for"'; | |
access_log /var/log/nginx/access.log main; | |
sendfile on; | |
#tcp_nopush on; | |
keepalive_timeout 65; | |
#gzip on; | |
include /etc/nginx/conf.d/*.conf; | |
# List of application servers | |
upstream manage { | |
server 172.17.0.2:9000; | |
} | |
upstream find3server { | |
server 172.17.0.3:8003; | |
} | |
upstream find3mqtt { | |
server 172.17.0.3:1883; | |
} | |
# Configuration for the servers | |
server { | |
# Running port | |
listen 0.0.0.0:80; | |
server_name manage.maps.goflo.in; | |
# Proxying the connections connections | |
location / { | |
proxy_http_version 1.1; | |
proxy_set_header Connection ""; | |
proxy_pass http://manage; | |
} | |
location /api/websocket/ { | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection "upgrade"; | |
proxy_http_version 1.1; | |
proxy_pass http://manage/api/websocket/; | |
} | |
} | |
server { | |
# Running port | |
listen 80; | |
server_name beta.maps.goflo.in; | |
# Proxying the connections connections | |
location / { | |
proxy_pass http://find3server; | |
proxy_redirect off; | |
proxy_set_header Host $host; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-Forwarded-Host $server_name; | |
} | |
} | |
server { | |
# Running port | |
listen 80; | |
server_name mqtt.maps.goflo.in; | |
# Proxying the connections connections | |
location / { | |
proxy_pass http://find3mqtt; | |
proxy_redirect off; | |
proxy_set_header Host $host; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-Forwarded-Host $server_name; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment