[英]reverse proxy with nginx ssl passthrough
我有幾個 ISS Webservers 在每個 IIS 服務器上托管多個 Web 應用程序。 每個系統上都有一個公共證書。 每個 IIS 都有一個唯一的 IP。 所有 IIS 服務器都放在同一個 DMZ 中
我在另一個 DMZ 中設置了一個 nginx 系統。 我的目標是,讓 nginx 處理從 Internet 到 IIS 的所有請求,並且只需將所有 SSL 和證書檢查傳遞給 IIS。 就像在 nginx 之前一樣。 我不想讓 nginx 分解證書,或者卸載它們等。
在我嘗試使用 nginx 反向代理來完成它之前(因為我對 nginx 不是很熟悉),我的問題是,這是否可能?
相信我,我已經在谷歌上搜索了很多次,但找不到可以回答我的問題的東西,或者也許我在谷歌上太愚蠢了。 我什至搜索了直通或反向代理卸載。
到目前為止,我已經收集到,nginx 可能需要一些額外的 mod。 由於我有一個“apt-get”安裝,我什至不知道如何添加它們。
沒關系我找到了解決方案:
問題:
解決方案:
要做的步驟:
1. 單個 nginx RP 應該放在 external-DMZ 上。
2. 配置 nginx: - 使用apt-get install nginx
在已打完補丁的 debian 上apt-get install nginx
。 此時,您將獲得適用於 nginx 的 1.14 版。 當然你也可以編譯
ngx_stream_ssl_preread, ngx_stream_map, and stream
。 別擔心,它們已經在包裹里了。 您可以使用nginx -V
檢查4.外部DNS配置: - 所有來自互聯網的DNS請求都應該指向nginx。
Eg webserver1.domain.com --> nginx webserver2.domain.com --> nginx webserver3.domain.com --> nginx
5.配置nginx反向代理
/etc/nginx/modules-enabled
在此處輸入代碼
stream {
map $ssl_preread_server_name $name {
webserver01.domain.com webserver01_backend;
webserver02.domain.com webserver02_backend;
}
upstream support_backend {
server 192.168.0.1:443; # or DNS Name
}
upstream intranet_backend {
server 192.168.0.2:443; # or DNS Name
}
log_format basic '$remote_addr [$time_local] '
'$protocol $status $bytes_sent $bytes_received '
'$session_time "$upstream_addr" '
'"$upstream_bytes_sent" "$upstream_bytes_received"
"$upstream_connect_time"';
access_log /var/log/nginx/access.log basic;
error_log /var/log/nginx/error.log;
server {
listen 443;
proxy_pass $name; # Pass allrequests to the above defined variable container $name
ssl_preread on;
}
}
6.取消鏈接默認的虛擬網絡服務器rm /etc/nginx/sites-enabled/default
7. 將所有 http 流量重定向到 https:
在此處輸入代碼
server {
listen 80;
return 301 https://$host$request_uri;
}
nginx -t
systemctl reload nginx
打開瀏覽器並在調用網絡服務器時檢查/var/log/nginx/access.log
結束
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.