Question

How to set up reverse proxy ssl for the wordpress category or post page

Posted October 25, 2021 89 views
Nginx

Hello, i am trying to set up a reverse proxy ssl for my wordpress domain. I have been able to set up the reverse proxy ip ssl for the wordpress, but it only apply for the main homepage. When i try to access the post or category or any other link inside the WordPress, it return with an error : 404 Not Found

I have been trying to find a solution or a guide regarding this, but so far i can not find how to solve this.

This is an example of how my set up for the reverse proxy

server {
        listen 80 default_server;
        server_name _;
        return 301 https://$host$request_uri;
}

server {
        #listen 80 default_server;
        #listen [::]:80 default_server ipv6only=on;

        listen 443 ssl ;
        listen [::]:443 ssl default_server;

        #ssl on;
        ssl_certificate         /etc/nginx/certificate.crt;
        ssl_certificate_key     /etc/nginx/private.key;

        root /var/www/html;
        index index.php index.html index.htm;

        # Make site accessible from http://localhost/
        server_name localhost;

        location / {

                proxy_pass https://example.com;
                proxy_ssl_server_name on;
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;
                # Uncomment to enable naxsi on this location
                # include /etc/nginx/naxsi.rules
        }

        error_page 404 /404.html;
        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
                root /usr/share/nginx/html;
        }

        location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php8.0-fpm.sock;
        }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #       deny all;
        #}
}
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!