Question

Nginx proxy for apache2 guide, mod_rewrite not working

  • Posted June 21, 2013

The guide followed was here: https://www.digitalocean.com/community/articles/how-to-configure-nginx-as-a-front-end-proxy-for-apache

I’ve setup everything and modified some other stuff to my liking, however as stated by another user, a fresh Wordpress install gives a redirect loop error on the index page. The dashboard works fine. To get around that error, I had to add remove_filter(‘template_redirect’, ‘redirect_canonical’); to the theme’s functions.php file.

Now I try to enable friendly urls with the .htaccess and it doesn;t work, it just reloads the same page no matter what I click. Is there something I’m missing?

My Nginx server block: https://paste8.com/KPMSQwXN My Apache vhost: https://paste8.com/q6BwHube

Any help is appreciated.

Subscribe
Share

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Your try_files changes the URL to /index.php in order to send it upstream which looses the pretty permalink.

You might try to send the pretty permalink upstream by adding a named location. Maybe:

location / { try_files $uri $uri/ @proxy; }

location @proxy { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header Host $host; proxy_pass http://127.0.0.1:8080; } location ~ .php$ { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header Host $host; proxy_pass http://127.0.0.1:8080; }

font https://serverfault.com/questions/755759/mod-rewrite-issue-apache-behind-nginx

Fixed the issue myself. <br> <br>New Nginx config: https://paste8.com/AetMDiCe