stream {
server {
listen SRC_IP:SRC_PORT;
proxy_pass DST_IP:DST_PORT;
}
}
更多细节请参考nginx文档 https://docs.nginx.com/nginx/admin-guide/load-balancer/tcp-udp-load-balancer/
server {
listen 443;
server_name myserver.mydomain.whatever;
ssl off;
access_log /var/log/nginx/myserver.access.log;
error_log /var/log/nginx/myserver.error.og;
keepalive_timeout 60;
location / {
set $fixed_destination $http_destination;
if ( $http_destination ~* ^https(.*)$ )
{
set $fixed_destination http$1;
}
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Destination $fixed_destination;
# Fix the “It appears that your reverse proxy set up is broken" error.
# might need to explicity set https://localip:port
proxy_pass $fixed_destination;
# force timeout if backend died.
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_read_timeout 90;
proxy_redirect http:// https://;
}
}
listen 80;
的服务器定义,我应该怎么做?将其重定向到主 nginx 服务器上的 443 然后使用您的代码示例吗?在您的示例中,您在哪里指定将请求转发到哪个内部 IP? - J J2015/10/22 11:34:21 [error] 18229#0: *57916 invalid URL prefix in "", client: xxx.xxx.xxx.xxx, server: my_server_name, request: "GET / HTTP/1.1$
或者浏览器直接显示无法建立安全连接并拒绝连接。 - J J