0

First of all, forgive me if I say something stupid, I have no experience with server administration but I've been assigned this task.

For our webapp we want to set up a proxy server so that clients owning domains of their own can point to our proxy server and their domain would effectively run as an alias of our app. We want to make this using a proxy server instead of them having to use the site's address directly in case something changes in the future.

I'm trying to do this in our staging server, which has the following nginx configuration for the main server:

server {
    listen 80;

    server_name staging.oursite.com;

    access_log /home/appname/logs/nginx-access.log;
    error_log /home/appname/logs/nginx-error.log;

    location /static/ {
        alias /home/appname/appname/static/;
        expires 365d;
    }

    location /site_media/ {
        alias /home/appname/appname/media/;
        expires 365d;
    }

    location / {
        include proxy_params;
        proxy_pass http://unix:/home/appname/run/gunicorn.sock;
    }

    error_page 502 /502.html;
    location = /502.html {
       root  /home/appname/appname/error_page/;
    }
}

My understanding is that all you need to set up a proxy is a new server block proxying to that other server, so I added the following directive below:

server {
    listen 80;

    server_name proxy.staging.oursite.com;

    location / {
        include proxy_params;
        proxy_pass http://staging.oursite.com;
    }
}

I restarted nginx to reload the new configuration but when going to proxy.staging.oursite.com I am just getting the following error:

502 Bad Gateway

2 Answers 2

0

The proxy_pass URL should end in a "/" too, else you get an invalid URL.

Try:

proxy_pass http://staging.oursite.com/;
0

I suggest to take a look into server access and error logs -> /var/log/nginx/error.log, /var/log/nginx/access.log

Also check if staging.oursite.com is accessible.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .