Welcome! Log In Create A New Profile

Advanced

Reverse proxy for non-localhost sites not working

Posted by xgage 
Reverse proxy for non-localhost sites not working
July 01, 2024 01:39PM
Hello, I have a setup for my Nginx reverse proxy to reverse proxy http://localhost:8080 from my main domain, with SSL setup using a Cloudflare Origin certificate and proxying with Cloudflare. When I try to change http://localhost:8080 to https://<another site>, Cloudflare returns 502 Bad Gateway.
Working code:

server {
location / {
proxy_pass http://localhost:8080
proxy_pass_request_headers on;
proxy_redirect off;
proxy_buffering off;
proxy_buffer_size 16k;
proxy_busy_buffers_size 24k;
proxy_buffers 64 4k;

}
listen 443 ssl;
ssl_certificate /etc/certs/cert.pem;
ssl_certificate_key /etc/certs/key.pem;
}

Not working code:

server {
location / {
proxy_pass https://<website>.com
proxy_set_header Host <website>.com;
proxy_pass_request_headers on;
proxy_redirect off;
proxy_buffering off;
proxy_buffer_size 16k;
proxy_busy_buffers_size 24k;
proxy_buffers 64 4k;

}
listen 443 ssl;
ssl_certificate /etc/certs/cert.pem;
ssl_certificate_key /etc/certs/key.pem;
}


Is there something special I have to add for https, or for non-local requests? Thanks!
Attachments:
open | download - image_2024-07-01_133509890.png (43.7 KB)
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 170
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready