duanbi7204 2014-12-08 11:13
浏览 120

Apache迁移到Nginx - connect()失败(111:连接被拒绝),同时连接到上游

I recently migrated a php (codeigniter) site from apache to nginx, there is a nodejs and html site already running on my nginx server.

I am seeing this error in error log of apache

connect() failed (111: Connection refused) while connecting to upstream, client: X.X.X.X, server: contextsdk-api.semusi.com, request: "POST /v1/Data HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "sdk-api.XXX.com"

Here is my nginx configuration

upstream api {
    server 127.0.0.1:9000;
}
server {
        listen   80;

        root /home/azureuser/contextsdkapi;
        server_name contextsdk-api.semusi.com;

        location / {
                try_files $uri $uri/ /index.php;
            }

        location ~ .php$ { ## Execute PHP scripts
            if (!-e $request_filename) { rewrite / /index.php last; }
            expires off; ## Do not cache dynamic content
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param MAGE_RUN_CODE default;
            fastcgi_param MAGE_RUN_TYPE store;
            include fastcgi_params;
        }

         location ~/\.ht {
        deny all;
    }

}

Update -

I changed my nginx configuration, location section to

 location ~ .php$ {
            try_files $uri =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass unix:/var/run/php5-fpm.sock;
            fastcgi_index index.php;
            include fastcgi_params;
    }

Now i am getting the error as -

connect() to unix:/var/run/php5-fpm.sock failed (13: Permission denied) while connecting to upstream
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 有偿求码,CNN+LSTM实现单通道脑电信号EEG的睡眠分期评估
    • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
    • ¥50 成都蓉城足球俱乐部小程序抢票
    • ¥15 yolov7训练自己的数据集
    • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
    • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
    • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)
    • ¥20 matlab yalmip kkt 双层优化问题
    • ¥15 如何在3D高斯飞溅的渲染的场景中获得一个可控的旋转物体
    • ¥88 实在没有想法,需要个思路