使用 nginx 做反向代理
基础版
配置网站:www.foodpanel.cn ```nginx server { server_name rd.foodpanel.cn;
location / {
root /usr/share/nginx/html/rdassist/dist;
try_files $uri $uri/ /index.html;
}
location /rdassist {
proxy_pass http://localhost:8082;
} }
<a name="9JgDS"></a>
## SSL 基础版
```nginx
server {
listen 443;
server_name fc.foodpanel.cn;
ssl on;
ssl_certificate /etc/nginx/SSL/fc.foodpanel.cn.pem;
ssl_certificate_key /etc/nginx/SSL/fc.foodpanel.cn.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 10m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
# 不缓存 html 文件
if ($request_filename ~* ^.*?.(html|htm)$){
add_header Cache-Control no-cache,no-store,must-revalidate;
}
root /usr/share/nginx/html/foodpanel/dist;
try_files $uri $uri/ /index.html;
}
location /srm {
proxy_pass http://localhost:8070;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
server {
listen 80;
server_name fc.foodpanel.cn;
rewrite ^(.*)$ https://$host$1 permanent;
}
SSL 最新版(nginx >= 1.15.0)
- 假设配置的网站为:www.zhugelong.cn
nginx版的SSL文件在 /etc/nginx/SSL 目录下 ```nginx server { listen 443 ssl; server_name www.zhugelong.cn;
root /usr/share/nginx/html/favorites/dist; index index.html;
ssl_certificate /etc/nginx/SSL/4071841_www.zhugelong.cn.pem; ssl_certificate_key /etc/nginx/SSL/4071841_www.zhugelong.cn.key;
ssl_session_timeout 5m; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on;
location / {
root /usr/share/nginx/html/rdassist/dist;
try_files $uri $uri/ /index.html;
}
}
server { listen 80; server_name www.zhugelong.cn; rewrite ^(.*)$ https://$host$1 permanent; }
```