Nginx 服務器的反向代理配置
Nginx 服務器的反向代理服務是其最常用的重要功能,由反向代理服務也可以衍生出很多與此相關的 Nginx 服務器重要功能。
反向代理配置示例:
- 1、HTTP反向代理配置
- 2、SSL反向代理配置
- 3、TCP反向代理配置
HTTP反向代理 nginx.conf 配置文件如下:
server {
listen 80;
location / {
proxy_pass http://127.0.0.1:8888;
index index.html;
}
}
SSL反向代理 nginx.conf 配置文件如下:
server {
listen 443 ssl;
server_name rest.kmbox.cn;
ssl_certificate "D:/AQBoxWeb/Nginx/conf/1_rest.kmbox.cn_bundle.crt";
ssl_certificate_key "D:/AQBoxWeb/Nginx/conf/2_rest.kmbox.cn.key";
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
proxy_redirect off;
proxy_pass http://127.0.0.1:9081;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
}
}
TCP/IP反向代理 nginx.conf 配置文件如下:
stream {
upstream server1{
server 127.0.0.1:1883;
}
server {
listen 88;
proxy_connect_timeout 50s;
proxy_timeout 50s;
proxy_pass server1;
}
}