VPS侦探论坛

 找回密码
 注册
查看: 3330|回复: 4

添加SSL后,无法使用https访问

[复制链接]
发表于 2020-9-6 16:36:03 | 显示全部楼层 |阅读模式

帮忙看下是哪个地方出问题
  1. [root@localhost 隐藏]# export Ali_Key="隐藏"
  2. [root@localhost 隐藏]# export Ali_Secret="隐藏"
  3. [root@localhost 隐藏]# lnmp onlyssl ali
  4. +-------------------------------------------+
  5. |    Manager for LNMP, Written by Licess    |
  6. +-------------------------------------------+
  7. |              https://lnmp.org             |
  8. +-------------------------------------------+
  9. /usr/local/acme.sh/acme.sh [found]
  10. Please enter domain(example: lnmp.org): 隐藏
  11. Your domain: 隐藏
  12. Enter more domain name(example: *.lnmp.org):
  13. Removing exist domain certificate...
  14. Starting create SSL Certificate use Let's Encrypt...
  15. [Sun Sep  6 15:58:38 CST 2020] Using CA: https://acme-v02.api.letsencrypt.org/directory
  16. [Sun Sep  6 15:58:38 CST 2020] Creating domain key
  17. [Sun Sep  6 15:58:39 CST 2020] The domain key is here: /usr/local/nginx/conf/ssl/隐藏/隐藏.key
  18. [Sun Sep  6 15:58:39 CST 2020] Single domain='隐藏'
  19. [Sun Sep  6 15:58:39 CST 2020] Getting domain auth token for each domain
  20. [Sun Sep  6 15:58:55 CST 2020] Getting webroot for domain='隐藏'
  21. [Sun Sep  6 15:58:55 CST 2020] 隐藏 is already verified, skip dns-01.
  22. [Sun Sep  6 15:58:55 CST 2020] Verify finished, start to sign.
  23. [Sun Sep  6 15:58:55 CST 2020] Lets finalize the order.
  24. [Sun Sep  6 15:58:55 CST 2020] Le_OrderFinalize='https://acme-v02.api.letsencrypt.org/acme/finalize/95739796/5046932167'
  25. [Sun Sep  6 15:59:01 CST 2020] Downloading cert.
  26. [Sun Sep  6 15:59:01 CST 2020] Le_LinkCert='https://acme-v02.api.letsencrypt.org/acme/cert/0465f28b5cec3dc559c5b3186e4146c2799b'
  27. [Sun Sep  6 15:59:07 CST 2020] Cert success.
  28. [Sun Sep  6 15:59:07 CST 2020] Your cert is in  /usr/local/nginx/conf/ssl/隐藏/隐藏.cer
  29. [Sun Sep  6 15:59:07 CST 2020] Your cert key is in  /usr/local/nginx/conf/ssl/隐藏/隐藏.key
  30. [Sun Sep  6 15:59:07 CST 2020] The intermediate CA cert is in  /usr/local/nginx/conf/ssl/隐藏/ca.cer
  31. [Sun Sep  6 15:59:07 CST 2020] And the full chain certs is there:  /usr/local/nginx/conf/ssl/隐藏/fullchain.cer
  32. [Sun Sep  6 15:59:07 CST 2020] Run reload cmd: /etc/init.d/nginx reload
  33. Reload nginx...  done
  34. [Sun Sep  6 15:59:07 CST 2020] Reload success
  35. ------------------ SSL Certificate information as follows ------------------
  36. | Domain: 隐藏
  37. | SSL Certificate: /usr/local/nginx/conf/ssl/隐藏/fullchain.cer
  38. | SSL Certificate Key: /usr/local/nginx/conf/ssl/隐藏/隐藏.key
  39. ------------------------------------ ---------------------------------------
  40. Let's Encrypt SSL Certificate create successfully.


  41. [root@localhost 隐藏]# ss -ntl
  42. State        Recv-Q       Send-Q             Local Address:Port             Peer Address:Port
  43. LISTEN       0            128                      0.0.0.0:111                   0.0.0.0:*
  44. LISTEN       0            128                      0.0.0.0:80                    0.0.0.0:*
  45. LISTEN       0            128                      0.0.0.0:80                    0.0.0.0:*
  46. LISTEN       0            128                      0.0.0.0:22                    0.0.0.0:*
  47. LISTEN       0            128                      0.0.0.0:443                   0.0.0.0:*
  48. LISTEN       0            128                            *:3306                        *:*
  49. LISTEN       0            128                         [::]:111                      [::]:*
  50. LISTEN       0            128                         [::]:22                       [::]:*
复制代码


下面是/usr/local/nginx/conf/vhost的配置文件

  1.         server {
  2.         listen 80;
  3.                 server_name 子域名隐藏 ;
  4.         index index.html index.htm index.php default.html default.htm default.php;
  5.         root  /home/wwwroot/子域名隐藏;
  6.                 location / { try_files $uri $uri/ /index.php?$query_string; }
  7.         #location /api { try_files $uri $uri/ /api.php?$query_string; }
  8.         #location /admin { try_files $uri $uri/ /admin.php?$query_string; }

  9.         location /flarum {
  10.               deny all;
  11.             return 404;
  12.         }

  13.         location ~* \.php$ {
  14.               fastcgi_split_path_info ^(.+.php)(/.+)$;
  15.               fastcgi_pass unix:/tmp/php-cgi.sock;
  16.               include fastcgi_params;
  17.               fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  18.               fastcgi_index index.php;
  19.         }
  20.    
  21.         location ~* \.html$ {
  22.               expires -1;
  23.         }

  24.         location ~* \.(css|js|gif|jpe?g|png)$ {
  25.               expires 1M;
  26.               add_header Pragma public;
  27.               add_header Cache-Control "public, must-revalidate, proxy-revalidate";
  28.         }

  29.         gzip on;
  30.         gzip_http_version 1.1;
  31.         gzip_vary on;
  32.         gzip_comp_level 6;
  33.         gzip_proxied any;
  34.         gzip_types application/atom+xml
  35.                    application/javascript
  36.                    application/json
  37.                    application/vnd.ms-fontobject
  38.                    application/x-font-ttf
  39.                    application/x-web-app-manifest+json
  40.                    application/xhtml+xml
  41.                    application/xml
  42.                    font/opentype
  43.                    image/svg+xml
  44.                    image/x-icon
  45.                    text/css
  46.                    text/plain
  47.                    text/xml;
  48.         gzip_buffers 16 8k;
  49.         gzip_disable "MSIE [1-6]\.(?!.*SV1)";
  50.                 }
  51. server
  52.     {
  53.         listen 443 ssl http2;
  54.         #listen [::]:443 ssl http2;
  55.         server_name 子域名隐藏 ;
  56.                 return 301 https://$server_name$request_uri;
  57.         index index.html index.htm index.php default.html default.htm default.php;
  58.         root  /home/wwwroot/子域名隐藏;

  59.         ssl_certificate /usr/local/nginx/conf/ssl/子域名隐藏/fullchain.cer;
  60.         ssl_certificate_key /usr/local/nginx/conf/ssl/子域名隐藏/子域名隐藏.key;
  61.         ssl_session_timeout 5m;
  62.         ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
  63.         ssl_prefer_server_ciphers on;
  64.         ssl_ciphers "TLS13-AES-256-GCM-SHA384:TLS13-CHACHA20-POLY1305-SHA256:TLS13-AES-128-GCM-SHA256:TLS13-AES-128-CCM-8-SHA256:TLS13-AES-128-CCM-SHA256:EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5";
  65.         ssl_session_cache builtin:1000 shared:SSL:10m;
  66.         # openssl dhparam -out /usr/local/nginx/conf/ssl/dhparam.pem 2048
  67.         ssl_dhparam /usr/local/nginx/conf/ssl/dhparam.pem;

  68.         include rewrite/other.conf;
  69.         #error_page   404   /404.html;

  70.         # Deny access to PHP files in specific directory
  71.         #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }

  72.         include enable-php-pathinfo.conf;

  73.         location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  74.         {
  75.             expires      30d;
  76.         }

  77.         location ~ .*\.(js|css)?$
  78.         {
  79.             expires      12h;
  80.         }

  81.         location ~ /.well-known {
  82.             allow all;
  83.         }

  84.         location ~ /\.
  85.         {
  86.             deny all;
  87.         }

  88.         access_log  /home/wwwlogs/子域名隐藏.log;
  89.     }
复制代码





顶顶顶
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2020-9-6 19:16:11 | 显示全部楼层


不清楚你说的无法访问是什么错误信息
单从你这新添加的https站点配置文件看你添加了301的代码是会导致重定向次数过多
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2020-9-6 19:19:19 | 显示全部楼层

licess 发表于 2020-9-6 19:16
不清楚你说的无法访问是什么错误信息
单从你这新添加的https站点配置文件看你添加了301的代码是会导致重定 ...

对,加了就是重定向过多,不加就无法加载全部内容
我的站点是forum.gitzaai.com
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2020-9-7 08:04:38 | 显示全部楼层



fzle8 发表于 2020-9-6 19:19
对,加了就是重定向过多,不加就无法加载全部内容
我的站点是forum.gitzaai.com ...

访问是正常的,显示也是正常
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2020-9-8 12:44:32 | 显示全部楼层

licess 发表于 2020-9-7 08:04
访问是正常的,显示也是正常

问题解决了,因为flarum的问题,需要在ssl服务框架里面还要加上一句代码
  1. location / { try_files $uri $uri/ /index.php?$query_string; }
复制代码

军哥运维代购:http://shop63846532.taobao.com/

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|VPS侦探 ( 鲁ICP备16040043号-1 )

GMT+8, 2024-9-21 11:04 , Processed in 0.026922 second(s), 16 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表