如何在php项目部署的同一服务器上发出“ GET”请求?

问题描述 投票:0回答:1

情况:

我使用nginx和fastcgi在机器A中将php项目部署为Web服务器,其配置文件如下:

server {
    listen       80;
    server_name  alpha.kimi.com;
    index index.html index.htm index.php;
    root /alidata/www/;
    location ~ .*\.(php|php5)?$
    {
            #fastcgi_pass  unix:/tmp/php-cgi.sock;
            fastcgi_pass  127.0.0.1:9000;
            fastcgi_index index.php;
            include fastcgi.conf;
    }

    location / {
        root   /www/admin/;
        index index.php;
        if (!-f $request_filename){
            rewrite ^/(.+)$ /index.php?$1& last;
        }
    }
    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
    {
            expires 30d;
    }
    location ~ .*\.(js|css)?$
    {
            expires 1h;
    }


    access_log  /data/log/nginx/access/output.log;
    error_log   /data/log/nginx/access/error.log;
}

因此,当我从本地计算机发出“ GET”请求时:

curl http://alpha.kimi.com/app/redirect/taskpush?build=10&gcdata=1

将会返回json

{"res":200,"msg":"success","extra":[]}

但是,当我在机器A中发出相同的请求时,它只是挂在那儿,什么也没有返回。 我也尝试过:

curl http://localhost/app/redirect/taskpush?build=10&gcdata=1

curl http://localhost:9000/app/redirect/taskpush?build=10&gcdata=1

都没有用。 我不知道是什么问题。

php nginx fastcgi
1个回答
0
投票

您需要将nginx配置为通过localhost或127.0.0.1进行侦听才能正常工作。

有关完整说明,请参见http://nginx.org/en/docs/http/ngx_http_core_module.html#listen

您可以添加多个监听语句,例如:

listen localhost;
listen 127.0.0.1;

另请参阅此以获取更多详细信息: https : //serverfault.com/questions/655067/is-it-possible-to-make-nginx-listen-to-different-ports

© www.soinside.com 2019 - 2024. All rights reserved.