mhe*_*dek 1 nginx nginx-location nginx-reverse-proxy
我的服务器侦听 443 端口并将请求重定向到服务器中的另一个端口。此外,我的服务器侦听 80 端口并在用户浏览http://www.xxxx.com时向用户显示静态内容
但我也想在用户浏览https://www.xxxx.com时显示静态内容
我该如何管理?我的 Nginx 配置文件是 ;
server {
listen 443 ssl;
server_name xxxx.com;
ssl_certificate /etc/nginx/ssl/nginx.crt;
ssl_certificate_key /etc/nginx/ssl/nginx.key;
location / {
expires off;
proxy_pass http://backend;
}
}
server {
listen 80;
listen [::]:80;
server_name xxxx.com;
root /var/www/xxxx.com/html;
index index.html;
location / {
try_files $uri $uri/=404;
}
}
Run Code Online (Sandbox Code Playgroud)
我想在用户使用https://www.xxxx.com浏览我的网站时显示我的 index.html 文件,并且我的代理将继续在后端工作
您可以调用命名位置作为try_files语句的默认操作。
例如:
location / {
try_files $uri $uri/ @proxy;
}
location @proxy {
proxy_pass http://backend;
}
Run Code Online (Sandbox Code Playgroud)
有关详细信息,请参阅此文档。
| 归档时间: |
|
| 查看次数: |
1492 次 |
| 最近记录: |