Question

Setting up Nginx(SSL) to reverse proxy to a wordpress site

I have Nginx with SSL installed on a digitalocean server and I want it to act as a reverse proxy to as wordpress site on different server. The wordpress install is not on a docker instance and does not have SSL also its hosted on port 8001. I am including an example of my config and what happens is the nginx url redirects to port 8001. So if I type domain.com to redirects to domain.com:8001 and gives me an ERR_SSL_PROTOCOL_ERROR

server {
    server_name domain.com www.domain.com;
    listen 80;

        # when the SSL is generated enable these lines and replace the example domain with yours
    listen 443 ssl http2;

   ssl_certificate /etc/letsencrypt/live/domain.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/domain.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

        location / {
                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $remote_addr;
                proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://wordpressurl:8001;
    }
}

Submit an answer

This textbox defaults to using Markdown to format your answer.

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

Sign In or Sign Up to Answer

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.

Hi @pundip,

I think the issue is because you are using an SSL and sending it alongside your request.

Try configuring just as a test a reverse proxy only with port 80 and a proxy_pass to 8001 and see if that does the trick.