问题原文
原帖链接 · 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.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
