thinkphp nginx配置文件

2 篇文章 0 订阅

server{
  listen 80;
  server_name xiaoqu168.com;
  return 301 https://$server_name$request_uri;
}

server {

    listen 443 ssl;
    #listen 80;
    server_name steak.youzhufang.cn;

    ssl_certificate /etc/letsencrypt/live/steak.youzhufang.cn/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/steak.youzhufang.cn/privkey.pem;
    ssl_session_cache shared:SSL:1m;
    ssl_session_timeout 5m;
    ssl_ciphers HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers on;

    access_log /data/wwwlogs/steak.youzhufang.cn_nginx.log combined;
    index index.html index.htm index.php;
    root /data/wwwroot/steak.youzhufang.cn/public;

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

    location ~ \.php {
        #fastcgi_pass remote_php_ip:9000;
        fastcgi_pass unix:/dev/shm/php-cgi.sock;
        fastcgi_index index.php;
        include fastcgi_params;
        set $real_script_name $fastcgi_script_name;
        if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
            set $real_script_name $1;
            set $path_info $2;
        }
        fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
        fastcgi_param SCRIPT_NAME $real_script_name;
        fastcgi_param PATH_INFO $path_info;
        fastcgi_param DEBUG 1;


        set $cors '';
        set $allow '';
        if ( $request_method = 'OPTIONS' ) { set $cors 'options'; }
        if ( $http_origin ~ "^(http://localhost:8080|http://peigou.wdouw.cn)$" ) {
            set $cors "${cors}1";
            set $allow 'allow';
        }

        if ($cors = 'options1') {
            add_header 'Access-Control-Allow-Origin' "$http_origin";
            add_header 'Access-Control-Allow-Methods' 'DELETE,POST,PUT';
            add_header 'Access-Control-Allow-Headers' 'Content-Type';
            add_header 'Access-Control-Max-Age' 1728000;
            add_header 'Content-Type' 'text/plain charset=UTF-8';
            add_header 'Content-Length' 0;
            add_header 'Access-Control-Allow-Credentials' 'true';
            return 204;
        }
        if ($allow = 'allow') {
            add_header 'Access-Control-Allow-Origin' "$http_origin";
            add_header 'Access-Control-Allow-Credentials' 'true';
        }
    }
    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ {
        expires 30d;
        access_log off;
    }
    location ~ .*\.(js|css)?$ {
        expires -1;
        access_log off;
    }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值