开发者社区> 问答> 正文

nginx反向代理的问题 - nginx报错

"

nginx配置的ci框架,端口是83

server {
        listen       83;
        server_name  evil.qtyd.com phpStudy.net;
        root   "E:/evil.qtyd.com/CodeIgniter-3.1.3";
        location / {
            index  index.html index.htm index.php;
            #autoindex  on;
        }
        location ~ \.php(.*)$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_param  PATH_INFO  $fastcgi_path_info;
            fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
            include        fastcgi_params;
        }
        
        location ^~ /get/ { #反向代理调试
           proxy_pass http://127.0.0.1:8787/;
        }
        
        if (!-e $request_filename) {
            rewrite ^/(.*)$ /index.php/$1 last;
            break;
        }
}

现在node监听了8787端口

router.get('/get.php', function (req, res) {
    console.log(req.query);
    res.header("Content-Type", "application/json;charset=utf-8");
  res.json(req.query);
  res.end();
})

我在浏览器访问http://127.0.0.1:83/get/get.php为什么没有跳过去

"

展开
收起
montos 2020-06-03 15:06:23 617 0
1 条回答
写回答
取消 提交回答
  • "

    求助..

    ######

    你监听的域名,为何用ip访问,这样根本就没走nginx

    ######回复 <a href=""https://my.oschina.net/u/3260405"" class=""referer"" target=""_blank"">@hdkevil : 不会啊,这俩没关系吧######回复 <a href=""https://my.oschina.net/u/2007432"" class=""referer"" target=""_blank"">@风翔飞 : proxy_pass只能设置在80端口才有用?不能吧?######回复 <a href=""https://my.oschina.net/u/3260405"" class=""referer"" target=""_blank"">@hdkevil : nginx.conf是默认的配置文件,需要在这个文件里配置才能访问其他配置文件,这个是主体######回复 <a href=""https://my.oschina.net/u/2007432"" class=""referer"" target=""_blank"">@风翔飞 : 我放在nginx.conf里可以了,原来放在vhosts.conf不行,这会有影响?######回复 <a href=""https://my.oschina.net/u/2007432"" class=""referer"" target=""_blank"">@风翔飞 : 127.0.0.1 - - [17/Feb/2017:10:55:55 +0800] "GET /get/get.php?device_port=ios HTTP/1.1" 404 583 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0######
     location ~ .php(.*)$ { fastcgi_pass   127.0.0.1:9000; fastcgi_index  index.php; fastcgi_split_path_info  ^((?U).+.php)(/?.+)$; fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name; fastcgi_param  PATH_INFO  $fastcgi_path_info; fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info; include        fastcgi_params; }

        location ^~ /get/ { #反向代理调试
           proxy_pass http://127.0.0.1:8787/;
        }</code></pre> 
    

    这两块,交换下位置

    ######表示没用######好,我试试######

    引用来自“风翔飞”的评论

    你监听的域名,为何用ip访问,这样根本就没走nginx

    效果算是出来了,具体的我再琢磨琢磨,谢谢

    "
    2020-06-03 15:48:22
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
《Nginx 代理系统常用手册》 立即下载
CentOS Nginx PHP JAVA 多语言镜像使用手 立即下载
CentOS Nginx PHP JAVA多语言镜像使用手册 立即下载