I have one nginx server setup(two config files) with two gunicorn web servers setup and running. One gunicorn is production and the other is staging.
I want nginx to serve http requests to xyz.com as well as https requests to xyz.com to the production gunicorn server @ 127.0.0.1:8000.
I have accomplished this with:
server {
listen 80;
server_name xyz.com;
return 301 https://$http_host$request_uri;
}
server {
listen 443 ssl;
server xyz.com;
..... <<< ssl stuff
location /{
.... proxy_stuff
proxy_pass http://127.0.0.1:8000;
}
}
I also want http traffic to xyz.com:8080 and https traffic to xyz.com:8080 to hit the staging server @ 127.0.0.1:8081. I have been been able to get https traffic to xyz.com:8080 working as follows:
server {
listen 8080 ssl;
server_name xyz.com;
...... << ssl stuff
location / {
...... << proxy stuff
proxy_pass http://127.0.0.1:8081;
}
}
But I can't seem to find a way to redirect http traffic at xyz.com:8080 to https traffic at xyz.com:8080. I have tried the same redirection that I did with port 80 but have not been successful.
Could use some direction.