大网数据广告活动
网站运营与故障问答

How to have 2 servers, different paths with same domain?

· 52CE 我爱测

Looking for some advice on the following: I'm wanting to have two servers with same domain. Not looking to have subdomains. Domain: https://example.com Server A: https://example.com/games/abcs13343/results Server B: https://examp…

问题原文

原帖链接 · YaBCK · CC BY-SA 4.0

Looking for some advice on the following:

I'm wanting to have two servers with same domain. Not looking to have subdomains.

Domain: https://example.com

Server A: https://example.com/games/abcs13343/results

Server B: https://example.com/blogs/games-blog-3

Is this achievable through doing a proxy reverse on Server A or is there a better way of doing something like this without subdomains?

已采纳解答

原帖链接 · Thanasis · CC BY-SA 4.0

Let's say you have your 2 servers, Server A and Server B with IP_A, IP_B respectively.

The HTTP/HTTPS requests come through ports and using a basic router only ports can be forwarded to each of your 2 local server IPs.

You can use 1 of your 2 servers to act as a proxy to the other server.

Firstly forward port 80 & 443 to the server A using its ip IPA.

Let the server with ip IPA, channel the requests to the other server(s) based on the requested URL.

Depending on what Server Software you use you need to follow different approaches.

In apache for port 80 you will need to edit your configuration file:

sudo gedit /etc/apache2/sites-available/000-default.conf

Add the lines at the end of <VirtualHost *.80>

<VirtualHost *.80>

....

RewriteRule ^/games/?(.*)$ http://{IPB}/games/$1 [P,L] 
ProxyPassReverse /games http://{IPB}/games

RewriteRule ^/blogs/?(.*)$ http://{IPB}/blogs/$1 [P,L] 
ProxyPassReverse /blogs http://{IPB}/blogs

    
</VirtualHost>

In each case, we added the ProxyPassReverse directive to ensure that any redirects issued by the backend are correctly passed on to the client.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2023-11-14)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。