I'm trying to set up nginx as a reverse proxy to serve all static assets, whilst forwarding all dynamic requests to Apache.
I've followed a load of different tutorials, none of which are giving me the desired effect.
My /etc/nginx/sites-available/default looks is as follows:
server { listen 81 default; server_name localhost; access_log /var/log/nginx/localhost.access.log; root /var/www/www.example.com/httpdocs; location / { try_files $uri @proxy; } location @proxy { proxy_set_header Host $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_buffers 32 4k; proxy_pass http://www.example.com:80; } location ~ \.php$ { proxy_pass http://www.example.com:80; } location ~ /\.ht { deny all; } } I'm using port 81 so as not to disrupt the running service.
Watching both the nginx and apache access logs I can see that all requests are still hitting both nginx, and being apache, that is all image, css and js requests as well.
If I comment out everything inside @proxy, static assets are served without issue.
As an additional problem I suppose, my rule for location ~ \.php$ is still serving unparsed PHP files.