nginx的使用

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;

        }

    }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值