在ubuntu中使用sudo a2enmod proxy
和sudo a2enmod proxy_http
。
在windows中使用去掉httpd.conf中的LoadModule proxy_module modules/mod_proxy.so
和LoadModule proxy_http_module modules/mod_proxy_http.so
前的註釋nginx
在windows中配置httpd.conf文件,在ubuntu中配置site_enabled中具體網站的參數apache
ProxyRequests Off <Proxy *> Require all granted </Proxy> ProxyPass /backward http://localhost:7000
server { listen 8000; # listen somename:8080; server_name somename alias another.alias; location / { proxy_pass https://www.piwheels.org; proxy_ssl_server_name on; proxy_redirect default; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } }
proxy_ssl_server_name on;是爲了解決一下問題:ubuntu
SSL_do_handshake() failed (SSL: error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure) while SSL handshaking to upstreamwindows
出現錯誤的緣由:
nginx反向代理的時候默認沒有將 server_name 發給上游服務(被代理的服務)。若是上游服務器配置了多個證書,這會致使上游服務器沒法給出正確的證書來通訊,進而致使握手失敗。開啓proxy_ssl_server_name指令後,nginx在與上游服務進行TLS協商時,會發送server_name。
proxy_redirect default;是爲了解決:
在服務器中有可能會進行403跳轉,打開該設置後,nginx會自動對域名進行替換。服務器