nginx 配置
server{
listen 80 //*部署的端口*
server_name //*部署的地址*
location /{ //*部署的位置*
root xxx/xxx/xxx //项目的根目录
index index.html //项目的入口文件
try_files $uri $uri/ /index.html //重定向到index.html
}
location /api { // 路径
proxy_pass http://xxx.com 配置反向代理
}
# nginx转发并添加请求头信息
location ^~ /demo {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header userid '123456789';
proxy_set_header X-Nginx-Proxy true;
proxy_pass http://10.10.10.25:443;
}
}
查看 nginx 错误
查看 nginx 配置,nginx.conf 里面写了错误日志的位置(error 文件路径)
## nginx 开启 ssl 配置
```conf
server {
listen 443 ssl;
server_name localhost;
ssl_client_certificate ssl/ca.crt;
ssl_verify_client on;
ssl_certificate cert.pem; # 客户端证书
ssl_certificate_key cert.key; # 私钥
ssl_session_cache shared:SSL:1m; # 设置ssl/tls会话缓存的类型和大小。
ssl_session_timeout 5m; # 客户端可以重用会话缓存中ssl参数的过期时间,
# intermediate configuration
ssl_protocols TLSv1.2 TLSv1.3; # 指令用于启动特定的加密协议 , ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2,
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-CHACHA20-POLY1305; # 加密套件
ssl_prefer_server_ciphers off; # 设置协商加密算法时,优先使用我们服务端的加密套件,而不是客户端浏览器的加密套件
location / {
root html;
index index.html index.htm;
}
}