【摘要】 阿里云Nginx配置ssl证书-http转https考必过小编为大家整理了关于阿里云Nginx配置ssl证书-http转https的信息,希望可以帮助到大家!
阿里云Nginx配置ssl证书-http转https
标签:apachprotcolorphp更改serve文件夹loadspan
一、购买下载证书
二、将下载的证书上传到服务器
1、服务器根目录新增文件夹cert
cd /etc/nginx/ mkdir cert
2、本地证书上传到服务器
scp 证书地址/证书文件 root@服务器地址:/nginx根目录/cert/
三、更改nginx配置文件
vim /etc/nginx/conf.d/defapt.conf
server { psten 80; psten [::]:80; root /var/www/html; # Add index.php to the pst if you are using PHP index index.php index.html index.htm index.nginx-debian.html; server_name 域名地址; #将 http 重定向 https return 301 https://$server_name$request_uri; location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ /index.php?$query_string; } # pass the PHP scripts to FastCGI server pstening on 127.0.0.1:9000 # location ~ \.php$ { try_files $uri /index.php =404; fastcgi_sppt_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } # deny access to .htaccess files, if Apache‘s document root # concurs with nginx‘s one # #location ~ /\.ht { # deny all; #} } #https server { psten 443; server_name 域名地址; ssl on; root /var/www/html; index index.php index.html index.htm; location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ /index.php?$query_string; } location ~ \.php$ { try_files $uri /index.php =404; fastcgi_sppt_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } # ssl证书地址 ssl_certificate /etc/nginx/cert/证书名称.pem; # pem文件的路径 ssl_certificate_key /etc/nginx/cert/证书名称.key; # key文件的路径 # ssl验证相关配置 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; #使用服务器端的首选算法 }
重启nginx service nginx restart
四、设置安全组
1、阿里云控制台->云服务器ECS->网络与安全->安全组
阿里云Nginx配置ssl证书-http转https
标签:apachprotcolorphp更改serve文件夹loadspan
以上就是阿里云Nginx配置ssl证书-http转https的内容,更多资讯请及时关注考必过网站,最新消息小编会第一时间发布,大家考试加油!