Nginx常见问题收集
Nginx常见问题收集
NGINX不允许向静态文件提交POST方式的请求,否则报405错误
telnet *.*.*.* 80
POST /map/navigation/2011winter/jsn/jsn_20120723_pack/pvf.jsn
HTTP/1.1
Host:*.*.*.* (2个回车)HTTP/1.1 405 Not Allowed
Server: MapbarServer
Date: Mon, 08 Oct 2012 05:34:53 GMT
Content-Type: text/html
Content-Length: 173
Connection: keep-alive
405 Not Allowed
405 Not Allowed
MapbarServer
经查发现:NGINX不允许向静态文件提交POST方式的请求,否则报405错误
解决办法:
1.在nginx vhosts配置文件中增加如下
error_page 405 =200 @405;location @405 {root /mapdata/www/datamobile/;proxy_method GET;proxy_pass http://map_tomcat;}
项目采用yaf和vue进行前后端分离,访问页面时正常. 但是刷新会报错.甚至有时候会请求不到页面.
- 这个情况主要是用vue采用前后端分离之后前端有在public下有一个单独的index.html
- 他们所有的页面都存放在这个index.html中.也就是说所有的页面请求都要打到这个文件中
- 所以如果我们通过传统的URL来请求页面比如登录,/user/login时会报错页面不存在
- 而我们的项目在部署的时候,将所有WEB和APP的接口都单独新建Module中
- 所以我们的接口请求,必然要有web或app字样,所以我们通过修改NGINX中的配置文件.
- 优先匹配带有app或web的URL,将其重置到public/index.php给yaf处理
- 而其他的都交给public/index.html来处理
server {listen 80;server_name otc.coinegg.im;access_log /home/work/logs/nginx/otc.coinegg.im.access.log main;error_log /home/work/logs/nginx/otc.coinegg.im.error.log;root /home/work/www/otc/public;# 禁止请求git相关的隐藏文件,这个也要放到前面来,只要在location / 前面location ~ /.git/ {deny all;}# 这个要放到前面了来, 做正则匹配,匹配到URL中含有WEB或APP时按照YAF重定向到index.php中location [/web/|/app/] {root /home/work/www/otc/public; # 除非路径不同否则这里不用重新定义rootindex index.php;if (!-e $request_filename) {rewrite ^/(.*)$ /index.php?$1 last;}}# 这要放到后面来, 即所有的请求全部重定向到index.html中location / {root /home/work/www/otc/public; # 除非路径不同否则这里不用重新定义rootindex index.html;try_files $uri $uri/ /index.html;}# 这里是FPM用的,保持不变即可location ~ \.php$ {index index.php;fastcgi_pass unix:/tmp/unix/php-cgi.sock;fastcgi_index index.php;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;include fastcgi_params;}
}
make -j2报错,我在ubuntu18.04下有这个错误
# make -j2如果报错:objs/Makefile:591: recipe for target 'objs/src/core/ngx_murmurhash.o' failed
# 我在ubuntu18.04下有这个错误
# 在objs/Makefile中将 -Werror 删除,对于warnings忽略
# vim objs/Makefile 找到第三行的CFLAGS = -I/usr/local/luajit/include/luajit-2.0 -pipe -O -W -Wall -Wpointer-arith -Wno-unused -Werror -g -DNDK_SET_VAR
# 删掉-Werrori 即可
转载于:https://my.oschina.net/chinaliuhan/blog/3074797
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
