今天部署一个前端程序, 访问时提示错误: 405 Not Allowed, 我的情况是用ajax请求json数据, 数据存在一个json文件中, 请求是报这个错误, 我的解决方式如下:
location / {
root /usr/share/nginx/html8085;
try_files $uri $uri/ /index.html;
index index.html index.htm;
error_page 405 =200 @405;
}
location @405 {
proxy_method GET;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#这里为本机的ip地址
proxy_pass http://10.0.128.59:8085$request_uri;
}