V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
NGINX
NGINX Trac
3rd Party Modules
Security Advisories
CHANGES
OpenResty
ngx_lua
Tengine
在线学习资源
NGINX 开发从入门到精通
NGINX Modules
ngx_echo
csensix
V2EX  ›  NGINX

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

  •  1
     
  •   csensix · 2013-09-29 15:44:53 +08:00 · 27323 次点击
    这是一个创建于 3859 天前的主题,其中的信息可能已经有所发展或是发生改变。
    大家下午好!

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

    服务器:nginx+php+MySQL

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

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

    新版本
    new.example.com

    或者另一个域名,甚至是本地host指定的ip的
    timothyye
        6
    timothyye  
       2013-09-29 17:11:20 +08:00 via Android
    用耳机域名更方便一些,赞同楼上
    timothyye
        7
    timothyye  
       2013-09-29 17:11:35 +08:00 via Android
    写错了,二级域名
    109109
        8
    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
        9
    Lax  
       2013-09-29 17:46:30 +08:00
    端口看起来很山寨,给人一种政府网站的感觉……

    对外服务一般还是用二级域名吧。
    shierji
        10
    shierji  
       2013-09-29 23:23:49 +08:00 via Android
    @Lax 哇湿胸
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5863 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 44ms · UTC 06:20 · PVG 14:20 · LAX 23:20 · JFK 02:20
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.