Nginx 配置二級虛擬目錄訪問 Laravel 重寫

楊圓建發表於2018-07-10
server {
    listen          80;
    listen          443 ssl http2;
    server_name     new.api.zentrust.cn;
    root            /var/www/new.api.zentrust.cn/prod/public;
    index           index.php index.html index.htm;
    etag on;

    gzip on;
    gzip_vary on;
    gzip_http_version 1.0;
    gzip_min_length 1k;
    gzip_buffers 4 16k;
    gzip_comp_level 2;
    gzip_disable msie6;
    gzip_types text/plain text/css application/json application/javascript application/x-javascript text/javascript text/xml application/xml application/xml+rss;

    client_max_body_size 110m;
    client_body_buffer_size 1024k;

    keepalive_timeout   60;

    sendfile on;
    sendfile_max_chunk 512k;
    tcp_nopush on;
    tcp_nodelay on;

    ssl_session_cache   shared:SSL:10m;
    ssl_session_timeout 30m;
    ssl_certificate /etc/nginx/ssl/new.api.zentrust.cn/fullchain.cer;
    ssl_certificate_key /etc/nginx/ssl/new.api.zentrust.cn/privkey.key;

    location ^~ /test {
        alias   /var/www/new.api.zentrust.cn/test/public;

        if (!-e $request_filename) {
                rewrite ^ /test/index.php last;
        }

        location ~ \.php$ {
                if (!-f $request_filename) {
                        return 404;
                }

                fastcgi_pass        unix:/tmp/php-fpm-72.sock;
                fastcgi_index       index.php;
                fastcgi_param       SCRIPT_FILENAME $request_filename;
                include             fastcgi_params;
        }
    }

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        fastcgi_pass        unix:/tmp/php-fpm-72.sock;
        fastcgi_index       index.php;
        fastcgi_param       SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include             fastcgi_params;
    }

    location = /robots.txt  { access_log off; log_not_found off; }
    location = /favicon.ico { access_log off; log_not_found off; }
}
本作品採用《CC 協議》,轉載必須註明作者和本文連結
smithyj

相關文章