nginx http https 配置案例

linux nginx 配置

server{
        listen 80;
        server_name www.worldsipo.com;
        index index.html index.htm index.php;
        root  /home/wwwroot/default/*****/public;

        #error_page   404   /404.html;
        #include enable-php.conf;
        include enable-php-pathinfo.conf;
        location /nginx_status
        {
            stub_status on;
            access_log   off;
        }
        location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
        }

        location ~ .*.(js|css)?$
        {
            expires      12h;
        }

        location ~ /.
        {
            deny all;
        }

        access_log  /home/wwwlogs/access-jiuling.log;
}

server{
    #listen 80;
    listen 443 ssl;
    server_name www.worldsipo.com;
    index index.htm index.php admin.php;
    try_files $uri $uri/ /index.html;
    root  /home/wwwroot/default/*****/public;
    ssl_protocols TLSv1.2 TLSv1.1 TLSv1;
    ssl_certificate worldsipo.com_chain.crt;
    ssl_certificate_key worldsipo.com_key.key;
    ssl_prefer_server_ciphers on;

	add_header Last-Modified $date_gmt;
    add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
    if_modified_since off;
    expires off;
    etag off;

    #error_page   404   /404.html;
    include enable-php-pathinfo.conf;
	
	location ^~ /admin.php {
        #allow 218.93.209.11;
	    #deny all;
        fastcgi_pass  unix:/tmp/php-cgi.sock;
	    #fastcgi_pass  127.0.0.1:9000;
        fastcgi_index index.php;
        include fastcgi.conf;
        include pathinfo.conf;
	}
	
    location /nginx_status
    {
        stub_status on;
        access_log   off;
    }

    #location / {
    #    if (!-e $request_filename) {
    #        rewrite  ^(.*)$  /index.php?s=/$1  last;
    #    }
    #}

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

    location ~ .*.(js|css)?$
    {
        #expires      -1;
        expires      12h;
    }

    location ~ /.
    {
        deny all;
    }

    access_log  /home/wwwlogs/access-jiuling.log;
}

相信坚持的力量,日复一日的习惯.
原文地址:https://www.cnblogs.com/pansidong/p/14435985.html