Nginx
重启 brew services restart nginx
server {
listen 7788;
server_name vue2.hht.test;
location / {
root /Users/sysadmin/code/vue_project/v2.cn.vuejs.org;
index index.html index.htm;
}
}
server {
listen 7788;
server_name vue3.hht.test;
location / {
root /Users/sysadmin/code/vue_project/docs-zh-cn/.vitepress/dist;
index index.html index.htm;
}
}
server {
listen 7788;
server_name vant.hht.test;
location /vant/ {
alias /Users/sysadmin/code/vue_project/vant/;
try_files $uri $uri/ /tparking/index.html;
index index.html;
add_header Access-Control-Allow-Origin *;
}
}
server {
listen 7788;
server_name bs.hht.test;
location / {
#root /Users/sysadmin/code/vue_project/better-scroll-docs/zh-CN;
#index index.html index.htm;
alias /Users/sysadmin/code/vue_project/better-scroll-docs/zh-CN/;
try_files $uri $uri/ /index.html;
index index.html;
add_header Access-Control-Allow-Origin *;
}
location /docs/ {
alias /Users/sysadmin/code/vue_project/better-scroll-docs/;
#try_files $uri $uri/ /tparking/index.html;
#index index.html;
#add_header Access-Control-Allow-Origin *;
}
}
server {
listen 7788;
server_name qa-tparking.hht.test;
# location / {
# root /Users/sysadmin/code/kerry_project/temporary-parking/dist;
# index index.html index.htm;
# # try_files $uri $uri/ router;
# }
location /tparking/ {
alias /Users/sysadmin/code/kerry_project/temporary-parking/dist/;
try_files $uri $uri/ /tparking/index.html;
index index.html;
add_header Access-Control-Allow-Origin *;
}
location /static/ {
alias /Users/sysadmin/code/kerry_project/temporary-parking/dist/static/;
# try_files $uri $uri/ /tparking/index.html;
# index index.html;
# add_header Access-Control-Allow-Origin *;
}
# location /tparking/static {
# root /Users/sysadmin/code/kerry_project/temporary-parking/dist/static;
# # index index.html index.htm;
# # try_files $uri $uri/;
# }
location router {
rewrite ^.*$ /index.html last;
}
}
server {
listen 7788;
server_name tp.hht.test;
add_header Access-Control-Allow-Origin http://localhost:8080 always;
# add_header Access-Control-Allow-Origin *;
# add_header Access-Control-Allow-Credentials true;
# $http_origin动态获取请求客户端请求的域 不用*的原因是带cookie的请求不支持*号
# add_header Access-Control-Allow-Origin $http_origin;
# # 表示请求头的字段 动态获取
# add_header Access-Control-Allow-Headers $http_access_control_request_headers;
#允许跨域请求的域,* 代表所有
# add_header 'Access-Control-Allow-Origin' 'http://localhost:8080' always;
#允许带上cookie请求
# add_header 'Access-Control-Allow-Credentials' 'true' always;
#允许请求的方法,比如 GET/POST/PUT/DELETE
# add_header 'Access-Control-Allow-Methods' *;
#允许请求的header
# add_header 'Access-Control-Allow-Headers' *;
# add_header Access-Control-Max-Age: 18000L
# if ($request_method = 'OPTIONS') {
# # add_header 'Access-Control-Allow-Origin' "$http_origin" always;
# # add_header 'Access-Control-Allow-Credentials' 'true' always;
# # add_header 'Access-Control-Allow-Headers' "Origin, X-Requested-With, Content-Type, Accept" always;
# # add_header 'Access-Control-Allow-Methods' * always;
# add_header 'Access-Control-Allow-Headers' * always;
# # add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
# # add_header 'Access-Control-Max-Age' 1728000;
# # add_header 'Content-Type' 'text/plain; charset=utf-8';
# # add_header 'Content-Length' 0;
# return 204;
# }
location / {
# add_header Access-Control-Allow-Origin 'http://localhost:8080';
# 表示允许这个域跨域调用(客户端发送请求的域名和端口)
# return 200 'rmja2iMHaYCiylSG2';
default_type text/html;
return 200 'rmja2iMHaYCiylSG2';
}
}
server {
listen 7788;
server_name h5.hht.test;
location /tparking {
proxy_pass http://localhost:8080;
# root /Users/sysadmin/code/vue_project/v2.cn.vuejs.org;
# index index.html index.htm;
}
}