【问题标题】:redirecting port using apache server使用apache服务器重定向端口
【发布时间】:2015-09-18 00:53:29
【问题描述】:

我有两个网站 http://localhost:8000/abchttp://localhost:9000/def 每个都部署在自己的 apache 服务器上。有什么办法可以省略端口并使用apache服务器通过从url映射来转移到相应的端口?

例如: http://localhost/abc 映射到端口 8000 http://localhost/def 映射到端口 9000

【问题讨论】:

标签: apache


【解决方案1】:

您确实可以,最简单的方法是代理。 你可以安装 ngenx 并配置它:

_ _ngenix_config_file__

location /abc {
    rewrite /abc/(.*) /$1 break;
    proxy_pass http://localhost:8000;
    proxy_redirect off;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

location /def {
    rewrite /def/(.*) /$1 break;
    proxy_pass http://localhost:9000;
    proxy_redirect off;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

这应该可以满足您的需求。当然,现在我们有 3 个网站。 如果其他 2 个实际上是在同一个 Apache 实例上运行, 重写您的 apache 配置以组合它们可能更有意义。 但是,无论他们发生了什么,以上都应该有效。

【讨论】:

  • 我试过了,url可以通过代理服务器重写。但它无法从“真实”服务器中检索资源。
猜你喜欢
  • 2011-09-30
  • 1970-01-01
  • 2021-08-20
  • 2014-12-02
  • 2013-09-06
  • 2012-08-17
  • 2013-11-29
  • 1970-01-01
  • 2011-01-15
相关资源
最近更新 更多