Nginx 配置 https

本文详细记录了手动配置HTTPS的过程,通过Nginx服务器实现安全连接。讲解了配置文件的关键参数,如监听端口、证书路径、加密协议等,并分享了在调试过程中遇到的问题及解决方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一直没有配置过https  ,最近手动配置下发现挺简单的,记录一下。

server {
    listen 443;
    server_name  interface.e-chains.cn;
    server_tokens off;

    ssl on;
    ssl_certificate /etc/ssl/e-chains.cn/bundle.cer;
    ssl_certificate_key /etc/ssl/e-chains.cn/privateKey.key;
    ssl_session_timeout 5m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;

 


location / {
        # expires -1;

        add_header app_remote_addr $remote_addr;
        add_header app_proxy_add_x_forwarded_for_ip $proxy_add_x_forwarded_for;

        #client_max_body_size 500m;
        try_files $uri $uri/  /index.php;
    }

    root /var/www/html/quzheng/thepeople_web/public;

index index.html index.htm index.nginx-debian.html;

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
   location ~ \.php.*$ {
        root          /var/www/html/quzheng/thepeople_web/public;   # root  的定义尽量使用绝对变量,决定了变量$document_root
        fastcgi_pass unix:/var/run/php-fpm/www.sock;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;

   }

}
apache  环境下不可以用   pcntl_fork  函数

只能在cgi  或命令行下使用。


Nginx 服务器无法获取  $_GET

try_files  $uri  $uri/  /index.php;

try_files $uri $uri/  /index.php?$args;


nginx 服务器   出现    file  not  found  是获取文件路径失败,最终发现是$document_root   变量  是  有root  控制的,所以root  要写成绝对地址,防止出现意想不到的结果。

location ~ xxxx  {

  root    xxxx

}

在调试代码的时候,出现500的时候,没有任何提示,可以通过配置的错误日志,查看nginx  服务器的错误。这是调试很重要的一点。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值