如何给nodejs开发的web|如何给nodejs开发的web 绑定域名
如下是我博客和在线工具的nginx配置文件(nginx.conf),大家可以参考下,虽然写的有点简单,但是还是好使的。
博客 (http://www.9958.pw) 用的nodejs,端口3000,在线工具 (http://tool.9958.pw) 用的是apache+php+mysql,端口8080,2个应用都是通过nginx前端代理转发请求到对应端口服务上的。
#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;
upstream nginx.9958.com {
server localhost:3000;
}server {
#nginx的监听端口
listen80;
#这里是请求域名
server_name9958.pw www.9958.pw;
#charset koi8-r;
#access_loglogs/host.access.logmain;
location / {
proxy_pass http://nginx.9958.com;
#请求转发到哪里
# roothtml;
# indexindex.html index.htm;
}#error_page404/404.html;
# redirect server error pages to the static page /50x.html
#
error_page500 502 503 504/50x.html;
location = /50x.html {
roothtml;
}# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
#proxy_passhttp://127.0.0.1;
#}# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
#roothtml;
#fastcgi_pass127.0.0.1:9000;
#fastcgi_indexindex.php;
#fastcgi_paramSCRIPT_FILENAME/scripts$fastcgi_script_name;
#includefastcgi_params;
#}# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
#denyall;
#}
}server {
listen80;
server_nametool.9958.pw;
#charset koi8-r;
#access_loglogs/host.access.logmain;
location / {
proxy_pass http://tool.9958.pw:8080;
# roothtml;
# indexindex.html index.htm;
}
error_page500 502 503 504/50x.html;
location = /50x.html {
roothtml;
}
}##############################################################################end weixin.9958.pw#################################### another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
#listen8000;
#listensomename:8080;
#server_namesomenamealiasanother.alias;
#location / {
#roothtml;
#indexindex.html index.htm;
#}
#}# HTTPS server
#
#server {
#listen443;
#server_namelocalhost;
#sslon;
#ssl_certificatecert.pem;
#ssl_certificate_keycert.key;
#ssl_session_timeout5m;
#ssl_protocolsSSLv2 SSLv3 TLSv1;
#ssl_ciphersHIGH:!aNULL:!MD5;
#ssl_prefer_server_cipherson;
#location / {
#roothtml;
#indexindex.html index.htm;
#}
#}}
【如何给nodejs开发的web|如何给nodejs开发的web 绑定域名】转载自:http://www.9958.pw/post/nodejs_domain
推荐阅读
- 喂,你结婚我给你随了个红包
- 考研英语阅读终极解决方案——阅读理解如何巧拿高分
- 如何寻找情感问答App的分析切入点
- 成交的种子咖啡冥想
- 一百二十三夜,请嫁给我
- mybatisplus如何在xml的连表查询中使用queryWrapper
- MybatisPlus使用queryWrapper如何实现复杂查询
- 每日一话(49)——一位清华教授在朋友圈给大学生的9条建议
- 历史教学书籍
- 如何在Mac中的文件选择框中打开系统隐藏文件夹