前端nginx配置

主站前端nginx配置说明

一、     主站

1.    具体内容

 

2.    SSL证书配置

433端口部分的配置为ssl证书配置。

其中,ssl_certificate与ssl_certificate_key字段对应证书所在目录与证书名

其他配置字段参考官网

3.    http强制转换为https

server/location中以下内容控制http强制转为https

rewrite ^(.*)$ https://$host$1 permanent

4.    React-Router中history路由处理

server/location中以下内容history路由处理,即,让http://finglodon.com/bx可通过浏览器输入直接访问

注意,http://会跳转到https://,所以也要处理https://finglodon.com/bx的history路由问题,故,433端口的server中也配置这一项

try_files $uri /index.html

二、     保险介绍页

1.    具体内容

 

2.    自动跳转配置

rewrite “/” https://finglodon.com/bx permanent

三、     静态资源服务配置

1.    不可访问目录

nginx默认没有目录浏览权限,需要开启浏览目录权限的话增加autoinedx on,默认是off。我们这里不需要,不加。

原文地址:https://www.cnblogs.com/zs-note/p/11981312.html