Nginx, HTTPS的配置

时间:2023-03-09 17:21:26
Nginx, HTTPS的配置

server {
listen 443;      ####HTTPS指定端口
server_name www.web.com;      #####域名或者IP

root /data/wwwroot/laravel/public;           #####项目所在绝对路径,项目入口
index index.php index.html index.htm ;

########################################################
## HTTPS ##
ssl on;

ssl_certificate /usr/local/nginx/cert/214235201250226.pem;
ssl_certificate_key /usr/local/nginx/cert/214235201250226.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;
#########################################################

try_files $uri $uri/ @rewrite;

location @rewrite { 
rewrite ^/(.*)$ /index.php?_url=/$1; 
}

location /nginx_status {
stub_status on;
access_log off;
allow 127.0.0.1;
deny all;
}

location ~ [^/]\.php(/|$) {
# fastcgi_pass remote_php_ip:9000;
fastcgi_pass unix:/dev/shm/php-cgi.sock;
fastcgi_index index.php;

####################################################
## HTTPS ##
fastcgi_param HTTPS on;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
####################################################

include fastcgi.conf;
}

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ {
expires 30d;
# access_log off;
}

location ~ .*\.(js|css)?$ {http://078886.cn/
expires 7d;
access_log off;
}

}