防盗链配置支持
#对源站点验证
valid_referers *.55c.om;
#非法引入会进入下方判断
if ($invalid_referer) {
return 404;
}
跨域
server {
listen 80;
server_name localhost;
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Headers X-Requested-With;
add_header Access-Control-Allow-Methods GET,POST,PUT,DELETE,OPTIONS;
if ($request_method = 'OPTIONS') {
return 204;
}
location / {
root /mnt/d/mydesign/linux/nginx/demo;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
server {
listen 8088;
server_name localhost;
location /VASC{
alias /VASC;
try_files $uri $uri/ /index.html=404;
index index.html index.htm;
}
location /HASC{
alias /HASC;
try_files $uri $uri/ /index.html=404;
index index.html index.htm;
}
location @router {
rewrite ^.*$ /index.html last;
}
location /ASCWEB/api/yunyingapi/{
rewrite ^.+yunyingapi/?(.*)$ /$1 break;
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Headers X-Requested-With;
add_header Access-Control-Allow-Methods GET,POST,PUT,DELETE,OPTIONS;
if ($request_method = 'OPTIONS') {
return 204;
}
proxy_pass http://124.126.16.98:8007/;
}
}
静态网站部署
单一路径映射
server {
listen 80;
server_name localhost;
location / {
root /mnt/d/mydesign/linux/nginx/demo;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
映射多个html
server {
listen 80;
server_name localhost;
location / {
root /mnt/d/mydesign/linux/nginx/demo;
index index.html index.htm;
}
#拼接到root后面
location /mmd {
root /mnt;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}