首页 > Web开发 > 详细

thinkphp5 + vue nginx配置

时间:2019-10-25 15:05:39      阅读:438      评论:0      收藏:0      [点我收藏+]

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;
    index index.php index.html index.htm;

    # For vue
    location / {
        root /var/www/xxx/dist/;
        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配置

原文:https://www.cnblogs.com/cshaptx4869/p/11737825.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!