Nginx常见问题有哪些

发布时间:2021-07-02 16:03:26 作者:chen
来源:亿速云 阅读:172

本篇内容介绍了“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

<html>
<head><title>405 Not Allowed</title></head>
<body bgcolor="white">
<center><h2>405 Not Allowed</h2></center>
<hr><center>MapbarServer</center>
</body>
</html>

经查发现: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进行前后端分离,访问页面时正常. 但是刷新会报错.甚至有时候会请求不到页面.

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; # 除非路径不同否则这里不用重新定义root
        index  index.php;
        
        if (!-e $request_filename) {
            rewrite ^/(.*)$ /index.php?$1 last;
        }
    }
    # 这要放到后面来, 即所有的请求全部重定向到index.html中
    location / {
        root   /home/work/www/otc/public; # 除非路径不同否则这里不用重新定义root
        index  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 即可

“Nginx常见问题有哪些”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注亿速云网站,小编将为大家输出更多高质量的实用文章!

推荐阅读:
  1. nginx常见问题整理和解决办法
  2. Sonar常见问题有哪些

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

nginx

上一篇:Spring Boot启动报错:internalTransactionalEventListenerFactory could not be registered如何解决

下一篇:Python中怎么实现动态规划

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》