nginx php 配置域名80 443

helei 2021-5-21 1,312 5/21
server
    {
        listen 80;
        #listen [::]:80;
        server_name www.baidu.com;
        index index.html index.htm index.php default.html default.htm default.php;
        root  /home/wwwroot/www.baidu.com;
        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-pathinfo.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  /home/wwwlogs/www.baidu.com.log;
    }
server
    {
        listen 443 ssl http2;
        #listen [::]:443 ssl http2;
        server_name www.baidu.com;
        index index.html index.htm index.php default.html default.htm default.php;
        root  /home/wwwroot/www.baidu.com;
        ssl_certificate /usr/local/nginx/conf/ssl/www.baidu.com.pem;
        ssl_certificate_key /usr/local/nginx/conf/ssl/www.baidu.com.key;
        ssl_session_timeout 5m;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
        ssl_prefer_server_ciphers on;
        ssl_ciphers "TLS13-AES-256-GCM-SHA384:TLS13-CHACHA20-POLY1305-SHA256:TLS13-AES-128-GCM-SHA256:TLS13-AES-128-CCM-8-SHA256:TLS13-AES-128-CCM-SHA256:EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5";
        ssl_session_cache builtin:1000 shared:SSL:10m;
        # openssl dhparam -out /usr/local/nginx/conf/ssl/dhparam.pem 2048
        ssl_dhparam /usr/local/nginx/conf/ssl/dhparam.pem;
        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-pathinfo.conf;
        
        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
        }
        location ~ .*\.(js|css)?$
        {
            expires      12h;
        }
        location ~ /.well-known {
            allow all;
        }
        location ~ /\.
        {
            deny all;
        }
        location ~ \.php(.*)$ {

			try_files      $uri =404;

			root /www/wwwroot/cdtrans/public;

            fastcgi_pass   127.0.0.1:9000;

            fastcgi_index  index.php;

            fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;

            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

            fastcgi_param  PATH_INFO  $fastcgi_path_info;

            fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;

            include        fastcgi_params;
        }
        access_log  /home/wwwlogs/www.baidu.com.log;
    }

thinkphp.conf

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

enabel-php.conf

location ~ [^/]\.php(/|$)
{
try_files $uri =404;
fastcgi_pass  unix:/tmp/php-cgi-71.sock;
fastcgi_index index.php;
include fastcgi.conf;
}

- THE END -

helei

5月21日12:56

最后修改:2021年5月21日
0

非特殊说明,本博所有文章均为博主原创。