nginx多个端口监听同一个域名

2013-09-29 15:44:53 +08:00
 csensix
大家下午好!

现在遇到一个问题,需要在同一台服务器上测试两个网站(新版本和旧版本)。希望能够通过同一个域名加上不同的端口来进行访问,不知是否可行,大家给提提建议吧。

服务器:nginx+php+MySQL

谢谢!
27365 次点击
所在节点    NGINX
10 条回复
est
2013-09-29 15:47:32 +08:00
这个属于最基础那一类问题吧。LZ有必要这么懒么。
csensix
2013-09-29 15:51:48 +08:00
@est 见笑了!我在找过一些资料,大概明白怎么操作。但v2ex的可靠,所以来这确认一下。
est
2013-09-29 16:17:36 +08:00
@csensix 你先说说你现在知道的改端口的方法?
coosir
2013-09-29 16:20:29 +08:00
修改nginx配置文件,比如默认的server监听80,照葫芦画瓢复制个改成其他端口
细节去搜索吧
felinx
2013-09-29 16:53:58 +08:00
不同子域名不是更简单吗?

比如正式的老版本是:
www.example.com

新版本
new.example.com

或者另一个域名,甚至是本地host指定的ip的
timothyye
2013-09-29 17:11:20 +08:00
用耳机域名更方便一些,赞同楼上
timothyye
2013-09-29 17:11:35 +08:00
写错了,二级域名
109109
2013-09-29 17:27:16 +08:00
server {
listen 80;
server_name www.google;

location / {
root /www;
index index.html index.htm;
}
}



server {
listen 8080;
server_name www.google;

location / {
root /www/new;
index index.html index.htm index.php;
#autoindex on;
#autoindex_exact_size off;
#autoindex_localtime on;
}
}
Lax
2013-09-29 17:46:30 +08:00
端口看起来很山寨,给人一种政府网站的感觉……

对外服务一般还是用二级域名吧。
shierji
2013-09-29 23:23:49 +08:00
@Lax 哇湿胸

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/84146

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX