I have a Sinatra app. I start two Thin servers listening on: 4567 and 4568. However, I have configured Nginx to only forward to 4567.
server {
listen 443;
listen [::]:443;
root /var/www/example/public;
index index.html index.htm index.nginx-debian.html;
server_name example.com www.example.com;
ssl on;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
ssl_session_timeout 30m;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://localhost:4567;
proxy_ssl_session_reuse off;
proxy_set_header Host $http_host;
proxy_pass_header Server;
proxy_cache_bypass $http_upgrade;
proxy_redirect off;
}
}
server {
listen 80;
server_name example.com www.example.com;
rewrite ^ https://$server_name$request_uri? permanent;
}
How can I also forward to 4678? I could duplicate the location block, changing only proxy_pass
but wouldn't that override the first location block? What is the correct way?