Apache 它能';可以在同一个域子目录中创建多个服务器
这只是我的项目。它正在成长,我想在同一个域中添加一个新服务器作为子目录。是否可以将子目录设置为: example.com 127.0.0.1 example.com/project1/127.0.0.2 example.com/project2/127.0.0.3Apache 它能';可以在同一个域子目录中创建多个服务器,apache,.htaccess,dns,Apache,.htaccess,Dns,这只是我的项目。它正在成长,我想在同一个域中添加一个新服务器作为子目录。是否可以将子目录设置为: example.com 127.0.0.1 example.com/project1/127.0.0.2 example.com/project2/127.0.0.3 如何配置DNS或Apache以使其工作?听起来您想要实现一个可以使用的代理。我假设站点已经在127.0.0.2和127.0.0.3上运行,公共前端在127.0.0.1 您需要在127.0.0.1上编辑配置文件,并在主配置(对于单个站点
如何配置DNS或Apache以使其工作?听起来您想要实现一个可以使用的代理。我假设站点已经在
127.0.0.2
和127.0.0.3
上运行,公共前端在127.0.0.1
您需要在127.0.0.1
上编辑配置文件,并在主配置(对于单个站点)或虚拟主机块中添加以下配置:
ProxyPass /project1/ http://127.0.0.2/
ProxyPass /project2/ http://127.0.0.3/
ProxyPassReverse /project1/ http://127.0.0.2/
ProxyPassReverse /project2/ http://127.0.0.3/
这将把来自/project1/
的所有请求发送到http://127.0.0.2/
,如果您想隐藏此服务器,或者公众无法访问此服务器(如内部网络地址),则需要设置反向代理,以便通过公共前端将结果反馈给用户,因此,您需要添加配置:
ProxyPass /project1/ http://127.0.0.2/
ProxyPass /project2/ http://127.0.0.3/
ProxyPassReverse /project1/ http://127.0.0.2/
ProxyPassReverse /project2/ http://127.0.0.3/
此外,您还需要在配置文件中启用代理模块,这些是我为基本反向代理启用的
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
根据您的情况,还有一些其他模块可能很重要
mod_proxy_connect This handles the CONNECT function if connecting to https:// servers
mod_proxy_ftp This handles connections to FTP servers
mod_proxy_ajp This handles connections to tomcat/AJP servers
mod_headers This can modify response and request headers
mod_deflate This negotiates compression with backends
mod_proxy_html This is a 3rd party module which will rewrite HTML links to the proxy address space
+1很好的解释,虽然在我看来OP是在谈论子域。但是,谁知道呢。