thinkphp5 + vue nginx配置

thinkphp5 + vue 配置
server {    listen 80;
    listen [::]:80;
    # For https
    listen 443 ssl;
    listen [::]:443 ssl;
    ssl_certificate /etc/nginx/ssl/xxx.pem;
    ssl_certificate_key /etc/nginx/ssl/xxx.key;
    if ($scheme = 'http')
    {
        return 301 https://$server_name$request_uri;
    }
    #auth
    auth_basic on;
    auth_basic_user_file /etc/nginx/ssl/.auth;
    #gzip
    gzip on;
    gzip_comp_level 6;
    gzip_min_length 1024;
    gzip_buffers 32 4K;
    gzip_types application/javascript text/css;
    server_name xxx;
    root /var/www/xxx/dist;
    index index.php index.html index.htm;
    # For vue
    location / {
        try_files $uri $uri/ /index.html;
    }
    location ~* \.(jpg|jpeg|png|gif|js|css|mtn)$ {
        expires 1d;
    }
    # For thinkphp5
    location ~ ^/api/ {
        if (!-e $request_filename) {
            rewrite  ^/api/(.*)$  /index.php?s=/$1  last;
        }
    }
    location ~ \.php$ {
        root /var/www/xxx/php/public;
        fastcgi_pass php-upstream;
        fastcgi_index index.php;
        fastcgi_buffers 16 16k;
        fastcgi_buffer_size 32k;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        #fixes timeouts
        fastcgi_read_timeout 600;
        include fastcgi_params;
    }
    location ~ /\.ht {
        deny all;
    }
    location /.well-known/acme-challenge/ {
        root /var/www/letsencrypt/;
        log_not_found off;
    }
    error_log /var/log/nginx/xxx_error.log;
    access_log /var/log/nginx/xxx_access.log;
}
vue部分还可以:
if (!-d $request_filename) {
      rewrite ^/(.+)/$ /$1 permanent;
}
以上是 thinkphp5 + vue nginx配置 的全部内容, 来源链接: utcz.com/z/379705.html






