4

I hope you can help me solving my issue.

I am running ngninx on a dedicated Server as a reverse proxy. My WordPress Application is on another VM, which is running apache2 as a Websever. Everything is working fine until I use "permalinks" in WordPress. I am receiving:

"The requested URL /contact-us/ was not found on this server."

Here is my config on nginx:

server {
        listen          443;
        ssl         on;
        server_name     foo.com;


        access_log  /var/log/nginx/foo.access.log;
        error_log   /var/log/nginx/foo.error.log;


        ssl_certificate           /etc/nginx/ssl-certificates/foo.de.crt;
        ssl_certificate_key       /etc/nginx/ssl-certificates/foo.de.key;


        ssl_protocols        SSLv3 TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers RC4:HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers on;
        keepalive_timeout    60;
        ssl_session_cache    shared:SSL:10m;
        ssl_session_timeout  10m;

        location / {
            proxy_pass  https://111.111.111.111;
            proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
            proxy_set_header        Host            $host;
            proxy_set_header        X-Real-IP       $remote_addr;
            proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
        }

}
server {
    listen      80;
    server_name     foo.com;

    add_header Strict-Transport-Security max-age=2592000;
    rewrite ^/.*$ https://$host$request_uri? permanent;
}

I don't know the reason why I can't use permalinks. Anyone facing the same Problem?

Thanks in Advanced!

  • Did you get it to work in the end? If so could you comment on how you fixed it please? It'd be interested to know - I'm just contemplating using nginx as a reverse proxy in a similar way (although without the VMs) – Pitt Aug 25 '16 at 4:22
  • Hi Pitt, I am still looking for a solution. But at the moment I am working on another issue. (nothing to do with this) – allinformatix Aug 26 '16 at 7:57
1

You're missing your Wordpress rewrite rules.

It's probably confusing because, in Apache, Wordpresss automatically generates the rewrite rules in .htaccess. It does not do the same in nginx environments.

Pay special attention to the Wordpress documentation on nginx and configuration directives referencing HTTP rewrite rules, the "includes" directives for segmenting configuration and the specific Wordpress rewrite rules that need to be present for pretty permalinks to work properly.

Without knowing a lot about your operating system, site/network or setup, I hesitate to copy and paste code without context. This section of the documentation is pretty thorough, and should provide what you're looking for.

  • 2
    I have been searching for a correct answer this question, but this answer is not it. The question is fairly specific to Apache with nginx reverse proxy. Unfortunately the documentation linked to does not at all handle this problem (more than a year after this was recommended as a solution). In fact none of the docs deal with an apache/nginx set using proxy_pass - if they did... a large portion of .htaccess would still remain working as it would still be handled by apache and .htaccess. Sadly I have such a setup and every re-write works flawless - except admin area. – Bruce May 9 '17 at 0:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.