1. 程式人生 > >Nginx配置站點https

Nginx配置站點https

HA nginx配置 站點 div home pro name param efault

step 1: 檢查nginx的編譯參數

使用nginx -V可以查看,如果編譯參數中包含http_ssl_module,可以繼續下一步操作,如果沒有,則需要從新編譯。

技術分享圖片

step 2: 申請證書

目前,阿裏雲等雲平臺可以申請一定時間的免費證書,這裏大家可以自行找下,不再多說

step 3: 配置nginx.conf

server {
    listen 443;
    server_name hae.top;
    ssl on;
    ssl_certificate      /usr/local/nginx/key/214665654330627.pem;
    ssl_certificate_key
/usr/local/nginx/key/214665654330627.key; ssl_session_timeout 5m; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; ssl_prefer_server_ciphers on; index index.html index.htm index.php; root /home/wwwroot/default/public;
location / { try_files $uri $uri/ /index.php$is_args$args; } location ~ [^/]\.php(/|$) { # comment try_files $uri =404; to enable pathinfo try_files $uri =404; fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_index index.php; include fastcgi.conf; fastcgi_param
PHP_ADMIN_VALUE "open_basedir = /home/wwwroot: /temp/:/proc"; } }

接著使用https訪問站點即可

Nginx配置站點https