Answer the question
In order to leave comments, you need to log in
How to redirect https request to another server (proxy_pass) in nginx?
Hello everyone
The task is to perform proxying through nginx, and the proxy is completely - only redirection.
http are redirected fine:
nginx:80 -> web1:80
nginx:80-> web2:80
nginx:443 -> error. That is, he stubbornly tries to find a certificate with himself, but he needs to send the request further to web3:443.
It's confusing, but the task is exactly the same, on nginx there are no ssl, etc., only proxy_pass and redirect_url.
All ssl and so on are stored directly on the final web servers.
No matter what I tried, nothing works. I'm already confused and a stupid enumeration of parameters begins.
Log errors:
no "ssl_certificate" is defined in server listening on SSL port while SSL handshaking
in browser "Secure Connection Failed"
I'd be grateful for a kick in the right direction.
UPD: right now, it works on http
server {
listen 80;
listen 443 ssl;
server_name example.com www.example.com;
location / {
proxy_pass https://example.com/ ;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
Answer the question
In order to leave comments, you need to log in
Of course it will not work, you need to get a certificate for your nginx, even a free one from Letsencrypt
Now you get a "Men in the middle" attack you cannot proxy requests because nginx acts as an SSL endpoint
Since you want it to work only for proxying via TCP protocol or try HAProxy for balancing
https://community.ptc.com/t5/IoT-Tech-Tips/HAProxy...
As you know, apache and nginx can keep several sites on the same port and IP at once, in fact, having a crutch
parsing the http referer headers.
But ask yourself the question, how can you get this referee on a channel that is not yet installed?
Actually, here is the answer;) if you want https - drive the keys at the beginning;) and then everything else
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question