I may need a little help here. I feel I am almost there but missed something in my setup.
I can connect to my .com/3000
to see my local node app running on server.
To connect to .com directly I just need to use proxy_pass so I did
proxy_pass http://127.0.0.1:3000
;
But it won't run.
I have a nodejs app running on localhost:3000 on server.
Below is my default file in /etc/nginx/sites-available
server {
listen 80 default_server;
listen [::]:80 default_server;
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
proxy_pass http://127.0.0.1:3000;
}
}
And here's my nginx.config file
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
include /etc/nginx/sites-enabled/*;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
index index.html index.htm;
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name localhost;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
}
# redirect server error pages to the static page /40x.html
#
error_page 404 /404.html;
location = /40x.html {
}
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
Update -
I am on Amazon Ec2 instance. The page at .com displays as
For root directive I have tried
root /var/www/app/index.html
and in this case it will just throw me 404 not found nginx page**root /var/www/app
and in this case it gives 403 forbidden error**
default_server
in both server blocks. Most probably the wrong one wins./usr/share/nginx/html
and gives me nginx welcome page. I tried to change this root to something else and it is now giving me 404 nginx page. For thedefault_server
line in both files of server block, please go ahead and mention the corrected version. I am not even sure how default and nginx.conf are playing together. Just sort it out for me