php-nginx|php-nginx 前后端分离(web history模式路由)配置

【php-nginx|php-nginx 前后端分离(web history模式路由)配置】nginx: v1.10.3
php: 5.6.37
前后端分离配置,可以有效处理vue-router的history模式,同时基于https
直接上配置吧

server { listen 8088 ssl http2 ; server_nameweb; proxy_read_timeout 120; proxy_send_timeout 120; ssl_certificate ssl.crt; ssl_certificate_key ssl.key; access_loglogs/web.8088.access.logmain; location ^~ /v1/ { if (!-e $request_filename) { rewrite ^/(.*)$ /index.php/$1 last; break; } }location / { root/webpath; indexindex.htm index.html index.php; try_files $uri $uri/ /index.html; } location ~ \.php/?.*$ { add_header 'Access-Control-Allow-Origin' '$http_origin'; add_header 'Access-Control-Allow-Credentials' 'true'; add_header 'Access-Control-Allow-Headers' 'Origin, X-Requested-With, Content-Type, Accept, content-type, x_requested_with'; add_header 'Access-Control-Allow-Methods' 'GET,POST,DELETE,PUT,OPTIONS'; if ($request_method = 'OPTIONS') { return 206; }root/serverpath; set $fastcgi_script_name2 $fastcgi_script_name; if ($fastcgi_script_name ~ "^(.+\.php)(/.+)$") { set $fastcgi_script_name2 $1; set $path_info $2; } fastcgi_pass127.0.0.1:9000; fastcgi_indexindex.php; fastcgi_read_timeout 6000; fastcgi_paramPATH_INFO $path_info; fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name2; fastcgi_paramSCRIPT_NAME$fastcgi_script_name2; } }

    推荐阅读