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;
backend
upstream?