用nginx配置node的程序,已经改了conf的配置,用域名无法访问?

我用pm2运行了一个node的示例程序(express的示例程序),目前可以用http://127.0.0.1:3000打开,现在我想用自己自定义的域名打开,但是我用nginx配置之后还是不能用自定义域名(http://mydomain.com)打开,用127.0.0.1或localhost是可以的,是不是还要在本机配置host呢?但是在网上找了一圈nginx配置经验或说明没有一个说还要改host,希望能有人解答。
附上nginx.conf的配置信息
#usernobody;
worker_processes1;
#error_loglogs/error.log;
#error_loglogs/error.lognotice;
#error_loglogs/error.loginfo;
#pidlogs/nginx.pid;
events{
worker_connections1024;
}
http{
includemime.types;
default_typeapplication/octet-stream;
#log_formatmain'$remote_addr-$remote_user[$time_local]"$request"'
#'$status$body_bytes_sent"$http_referer"'
#'"$http_user_agent""$http_x_forwarded_for"';
#access_loglogs/access.logmain;
sendfileon;
#tcp_nopushon;
#keepalive_timeout0;
keepalive_timeout65;
#gzipon;
upstreamnodejs{
server127.0.0.1:3000;
}
server{
listen80;
server_namewww.mydomain.commydomain.com;
#charsetkoi8-r;
#access_loglogs/host.access.logmain;
location/{
proxy_set_headerX-Real-IP$remote_addr;
proxy_set_headerX-Forwarded-For$proxy_add_x_forwarded_for;
proxy_set_headerHost$http_host;
proxy_set_headerX-Nginx-Proxytrue;
proxy_set_headerConnection"";
proxy_passhttp://nodejs;
#roothtml;
#indexindex.htmlindex.htm;
}
#error_page404/404.html;
#redirectservererrorpagestothestaticpage/50x.html
#
error_page500502503504/50x.html;
location=/50x.html{
roothtml;
}
}
includeservers/*;
}
繁星coding
浏览 591回答 2
2回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript