1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
| server { listen 82; server_name localhost; # 采用 https 可以启用 # rewrite ^(.*)$ https: location /{ # 开启CORS支持 add_header 'Access-Control-Allow-Origin' '*' always; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always; add_header 'Access-Control-Max-Age' 1728000 always; add_header 'Access-Control-Allow-Credentials' 'true' always; add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization' always;
# 针对预检请求的特殊处理 if ($request_method = 'OPTIONS') { add_header 'Content-Type' 'text/plain charset=UTF-8'; add_header 'Content-Length' 0; return 204; } # 指定静态资源的根目录,root后可设置相对路径,也可以设置绝对路径,根据需求设定 root /etc/nginx/html/live2d;
}
location ~* ^/(get|add|rand|rand_textures|switch|switch_textures|tools)(/?.*)$ { # 开启CORS支持 add_header 'Access-Control-Allow-Origin' '*' always; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always; add_header 'Access-Control-Max-Age' 1728000 always; add_header 'Access-Control-Allow-Credentials' 'true' always; add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization' always;
# 针对预检请求的特殊处理 if ($request_method = 'OPTIONS') { add_header 'Content-Type' 'text/plain charset=UTF-8'; add_header 'Content-Length' 0; return 204; } # 跟上面 php-fpm 对应 fastcgi_pass unix:/run/php/php-fpm.sock; fastcgi_index index.php; # 修改自己项目的对应目录, 项目存放在/etc/nginx/html/live2d/ 下面 fastcgi_param SCRIPT_FILENAME /etc/nginx/html/live2d/$fastcgi_script_name; include fastcgi_params; }
error_page 500 502 503 504 /50x.html; # 指定报错页面
location = /50x.html { root html; } } server { listen 446 ssl; #监听端口 server_name localhost; #请求域名 ssl on; #开启ssl ssl_certificate /etc/nginx/conf.d/cert/example.com.pem; #pem证书路径 ssl_certificate_key /etc/nginx/conf.d/cert/example.com.key; #pem证书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协议
location /{ # 开启CORS支持 add_header 'Access-Control-Allow-Origin' '*' always; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always; add_header 'Access-Control-Max-Age' 1728000 always; add_header 'Access-Control-Allow-Credentials' 'true' always; add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization' always;
# 针对预检请求的特殊处理 if ($request_method = 'OPTIONS') { add_header 'Content-Type' 'text/plain charset=UTF-8'; add_header 'Content-Length' 0; return 204; } # 指定静态资源的根目录,root后可设置相对路径,也可以设置绝对路径,根据需求设定 root /etc/nginx/html/live2d;
}
location ~* ^/(get|add|rand|rand_textures|switch|switch_textures|tools)(/?.*)$ { # 开启CORS支持 add_header 'Access-Control-Allow-Origin' '*' always; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always; add_header 'Access-Control-Max-Age' 1728000 always; add_header 'Access-Control-Allow-Credentials' 'true' always; add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization' always;
# 针对预检请求的特殊处理 if ($request_method = 'OPTIONS') { add_header 'Content-Type' 'text/plain charset=UTF-8'; add_header 'Content-Length' 0; return 204; } # 跟上面 php-fpm 对应 fastcgi_pass unix:/run/php/php-fpm.sock; fastcgi_index index.php; # 修改自己项目的对应目录, 项目存放在/etc/nginx/html/live2d/ 下面 fastcgi_param SCRIPT_FILENAME /etc/nginx/html/live2d/$fastcgi_script_name; include fastcgi_params; }
error_page 500 502 503 504 /50x.html; # 指定报错页面
location = /50x.html { root html; }
}
|