之前使用443埠配置域名,直接使用埠訪問無需使用證書
之后做小程式需要配置https,配置之后發現之前的443無法訪問顯示:
400 The plain HTTP request was sent to HTTPS portnginx
443配置如下
server
{
listen 443;
#listen [::]:80;
server_name a.a.cn;
index index.html index.htm index.php default.html default.htm default.php;
root /home/project/test/test;
include rewrite/thinkphp.conf;
#error_page 404 /404.html;
# Deny access to PHP files in specific directory
#location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }
include enable-php.conf;
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
location ~ /.well-known {
allow all;
}
location ~ /\.
{
deny all;
}
access_log off;
}
https配置如下:
server
{
listen 443 ssl;
#listen [::]:80;
server_name b.b.cn;
index index.html index.htm index.php;
root /home/laravel/test/test;
include rewrite/laravel.conf;
#error_page 404 /404.html;
# Deny access to PHP files in specific directory
#location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }
include enable-php7.2.conf;
ssl_certificate cert/4544928_b.b.cn.pem; #將domain name.pem替換成您證書的檔案名。
ssl_certificate_key cert/4544928_b.b.cn.key; #將domain name.key替換成您證書的密鑰檔案名。
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
location ~ /.well-known {
allow all;
}
location ~ /\.
{
deny all;
}
access_log off;
}
https可以正常訪問
但是通過443埠訪問不行

轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/208564.html
標籤:專題技術討論區
