Nginx vue website && inner wordpress

server {
listen *:80;
listen *:443 ssl;
listen [::]:80;
listen [::]:443 ssl;
server_name www.example.com;

ssl_certificate /usr/local/nginx/ssl/example_com_ssl/examplecom.pem;
ssl_certificate_key /usr/local/nginx/ssl/example_com_ssl/server.key;
return 301 https://example.com$request_uri;
}
server {
listen *:80;
listen [::]:80;
server_name example.com;
return 301 https://example.com$request_uri;
}

server {
listen *:443 ssl;
listen [::]:443 ssl;
server_name example.com;

ssl_certificate /usr/local/nginx/ssl/example_com_ssl/examplecom.pem;
ssl_certificate_key /usr/local/nginx/ssl/example_com_ssl/server.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;


index index.php index.htm index.html;
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
root /var/lib/jenkins/workspace/website/EXAMPLE_VIEW_UK;
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
location / {
try_files $uri $uri/ @router;#需要指向下面的@router否则会出现vue的路由在nginx中刷新出现404
index index.html index.htm;
deny 112.64.88.25;
deny 112.64.89.162;
deny 207.46.150.254;
deny 52.175.48.72;
deny 23.101.5.86;
}

location /sa {
alias /var/lib/jenkins/workspace/website/EXAMPLE_VIEW_UK/sa;
index index.html;
try_files $uri $uri/ /sa/index.html;
if ( !-e $request_filename) {
rewrite ^ /sa/index.html last;
}
}

location /lp {
alias /var/lib/jenkins/workspace/website/EXAMPLE_VIEW_UK/lp;
index index.php;
try_files $uri $uri/ /lp/index.php?$query_string;

}

location ~ \.php {
add_header Access-Control-Allow-Origin * always;
add_header Access-Control-Allow-Methods * always;
add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
if ($request_method = 'OPTIONS') {
return 204;
}
fastcgi_pass 127.0.0.1:9000;
fastcgi_index /index.php;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

location @router {
rewrite ^.*$ /index.html last;
}

location /api/ {
rewrite ^/b/(.*)$ /$1 break;
proxy_pass https://userapi.example.com;
}

location /api/payment/ {
rewrite ^/b/(.*)$ /$1 break;
proxy_pass https://userapi.example.com;
}


rewrite ^/news https://example.com/GBP/en/news/blog-posts permanent;

proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
error_log /usr/local/nginx/logs/error_prod_example_website_log;
access_log /usr/local/nginx/logs/access_prod_example_website_log;


}
posted @ 2022-10-18 16:17  大漠孤烟~  阅读(37)  评论(0编辑  收藏  举报