Issues Configuring Reverse Proxy (NGINX/Caddy) with Plesk and Cloudflare

154 Views Asked by At

I'm currently working to set up a reverse proxy (NGINX, then Caddy) in front of a Plesk server, with Cloudflare for DNS and CDN. I have been facing several issues and I'm hoping someone here might help point me in the right direction.

Here is my setup:

  1. I have a Plesk server that's hosting my website.

  2. I am using another server as a reverse proxy to the Plesk server. Originally, I tried setting this up with NGINX and then switched to Caddy to see if it would resolve my issues.

  3. In Cloudflare, DNS entries are configured to direct my domain traffic to the reverse proxy server.

  4. SSL/TLS mode on Cloudflare is set to "Full". (I also tried Flexible)

My issues are:

  1. I cannot access my website using my domain. It results in a 522 error.

  2. When I remove the reverse-proxy layer and configure my DNS in Cloudflare to point directly to the Plesk server, everything works fine.

  3. I have tried changing between different SSL/TLS modes in Cloudflare, but the issue remains.

  4. I encountered a redirection loop ("redirected you too many times") issue when I switched from NGINX to Caddy. I'm looking for guidance on how to properly configure my reverse proxy to work with the Plesk server and Cloudflare. Please ask if you need more details about my configurations, and I'll provide as much info as I can.

I have tried the following NGINX configuration in the reverse proxy:

worker_processes 1;
events { worker_connections 1024; }


http {
 server {
    listen 80;
    server_name example.com;

    location / {
        proxy_pass https://loadbalancer-dns-link;
        proxy_set_header HOST "example.com";
        proxy_redirect   off;
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    }
 }
}

I expected this configuration to properly route requests to the Plesk server through the reverse proxy and resolve the mentioned issues. However, I've encountered the problems described above.

0

There are 0 best solutions below