0

I'm in the midst of a significant rewrite/update of group of services and am struggling with geting Apache/Nginx/Django to play nice with each other.

What's happening here is there is an internal application and API endpoints written using Django and hooked into Apache via mod_wsgi. This is all running on port 8080. Following Django best practices, I'm using nginx as a proxy to serve up the static assets, while letting root content go to the Django application. So, nginx is listening on port 80 and routing any traffic that does not start with /static/ to port 8080.

We have a wordpress site with a custom plugin that consumes the endpoints in the Django application. What I'd like to do is have the wordpress run on port 8091, but have any urls like localhost/wp/ hit the WP site.

Unfortunately, right now I'm just getting 404s any time I try to access the individual sites via port 80. Hitting localhost:8080 and localhost:8091 show the expected applications, but not via straight localhost.

nginx.conf:

upstream backend {
        server localhost:8080;
}

server {
        listen 80;
        server_name www.staging.com staging.com staging-local;

        access_log /home/mainuser/projects/update/logs/nginx_access.log;
        error_log  /home/mainuser/projects/update/logs/nginx_error.log info;

        location /wp/ {
                proxy_pass http://localhost:8901;
                include /etc/nginx/proxy_params;
        }

        location /static/ {
                root /home/mainuser/projects/update/server/data/static;
        }

         location / {
                proxy_pass http://localhost:8080;
                include /etc/nginx/proxy_params;
        }
}

proxy_params:

proxy_redirect  off;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size        10m;
client_body_buffer_size     128k;
proxy_connect_timeout       90;
proxy_send_timeout          90;
proxy_read_timeout          90;
proxy_buffer_size           4k;
proxy_buffers               4 32k;
proxy_busy_buffers_size     64k;
proxy_temp_file_write_size  64k;
2
  • Where are you actually using the backend upstream?
    – kaiser
    Mar 2, 2016 at 21:39
  • @kaiser not sure. I think that is an unused artifact
    – Jason
    Mar 2, 2016 at 22:36

1 Answer 1

0

You have an unused upstream named backend where you are pointing nothing at the moment. Straight from the Nginx upstream docs:

upstream backend {
    server backend1.example.com      weight=5;
    server backend2.example.com:8080 fail_timeout=5s slow_start=30s;
    server backend3.example.com      resolve;

    server backup1.example.com:8080  backup;
    server backup2.example.com:8080  backup;
}

server {
    location / {
        proxy_pass http://backend;
    }
}

The port gets set in the upstream, not the proxy_pass directive.

You must log in to answer this question.

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