I have already running app on nginx built in node.js, Now I have to create another app using php, should also run on nginx on same machine, like If I call "127.0.0.1:3001" then node application should run and if I call "127.0.0.1:3002", then php application should call.
Here is my nignx config file (/etc/nginx/site-available/default)
upstream app_stat {
server 127.0.0.1:3001;
keepalive 80;
}
#upstream app_php {
# server 127.0.0.1:3002;
# keepalive 80;
#}
server {
listen 80 default_server;
#listen [::]:80 default_server ipv6only=on;
root /home/manish/workspace/statistics;
index index.html index.htm;
# Make site accessible from http://localhost/
server_name localhost;
# static resources
location ~ ^/(robots.txt|humans.txt|favicon.ico) {
root /home/manish/workspace/statistics;
access_log on;
expires max;
}
location ~ /js/(.*) {
add_header X-debug-message "A static file was served by pushstate";
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass http://app_stat;
}
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
# try_files $uri $uri/ =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
if ($http_user_agent ~ (Googlebot|google|bing|yandex|msnbot|AltaVista|DuckDuckBot) ) {
return 403;
}
add_header X-debug-message $http_accept;
# break;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass http://app_stat;
}
}
server {
listen 80;
listen [::]:80 ipv6only=on;
server_name localhost;
root /var/www;
index index.php index.htm index.html;
# location / {
# try_files $uri $uri/ =404;
# proxy_pass http:localhost:3002;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_set_header Host $http_host;
# proxy_set_header X-Forwarded-Proto $scheme;
# proxy_buffering off;
# }
location ~/.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:3002;
fastcgi_index index.html;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Now When I start, nginx service, it started, and run 127.0.0.1:3001 (node app), it's running OK, but when I call 127.0.0.1:3002 (php), ERR_CONNECTION_REFUSED error occured, why?