【发布时间】:2014-04-07 07:31:18
【问题描述】:
我正在尝试使用 nginx (v1.5.11) 为我的节点项目设置域,我已成功将域重定向到网络,但我需要使用 3000 端口,所以现在,我的网络位置看起来像http://www.myweb.com:3000/ 当然,我只想保留“www.myweb.com”这样的部分:http://www.myweb.com/
我搜索并尝试了许多配置,但似乎没有一个适合我,我不知道为什么,这是我本地的 nginx.conf 文件,我想将 http://localhost:8000/ 文本更改为 http://myName/ 文本,请记住重定向有效,我只想“隐藏”该位置的端口。
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#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 logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 8000;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
proxy_pass http://localhost:8000/;
proxy_redirect http://localhost:8000/ http://myName/;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
pd。我正在尝试在本地 Windows 8 机器上修复它,但如果需要其他操作系统,我的远程服务器可以在 Ubuntu 12.04 LTS 上运行
谢谢大家。
【问题讨论】:
-
似乎您的 proxy_pass 指向您的服务器侦听的同一个 localhost:8000。将监听端口更改为 80。
标签: node.js redirect nginx location