![使端口显示为子域](https://linux22.com/image/693764/%E4%BD%BF%E7%AB%AF%E5%8F%A3%E6%98%BE%E7%A4%BA%E4%B8%BA%E5%AD%90%E5%9F%9F.png)
我已设置 Jira 来提供服务myserver:8080
。
有一个 DNS A 引用指向jira.otherserver
的 IP 地址myserver
。(otherserver
将来会托管 Jira 设置)
根据此处的其他答案,我尝试启用 mod_proxy,并将以下内容添加到我httpd.conf
的myserver
:
<VirtualHost *:80>
ServerName jira.otherserver/
ProxyPreserveHost On
# setup the proxy
<Proxy *>
Order allow,deny
Allow from all
</Proxy>
ProxyPass http://jira.otherserver/ http://localhost:8080/
ProxyPassReverse http://jira.otherserver/ http://localhost:8080/
</VirtualHost>
但是,当我访问时,http://jira.otherserver
它给出了通用的起始页 (phpinfo)。我仍然可以通过以下方式访问 jira:http://myserver:8080
我究竟做错了什么?
编辑:我也可以访问 Jira jira.otherserver:8080
,因此 DNS 工作正常
编辑 2:我按照答案中的建议,将该部分修改为
NameVirtualHost *:80
<VirtualHost *:80>
ServerName jira.software-task
ProxyPreserveHost On
# setup the proxy
<Proxy *>
Order allow,deny
Allow from all
</Proxy>
ProxyPass "/" "http://localhost:8080/"
ProxyPassReverse "/" "http://localhost:8080/"
</VirtualHost>
现在连接jira.otherserver
会导致错误 500,日志中出现以下内容:
[Fri Nov 18 13:40:03 2016] [warn] proxy: No protocol handler was valid for the URL /. If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule.
httpd -M
输出以下内容:
M:\>httpd -M Loaded Modules: core_module (static) win32_module (static) mpm_winnt_module (static) http_module (static) so_module (static) actions_module (shared) alias_module (shared) asis_module (shared) auth_basic_module (shared) authn_alias_module (shared) authn_default_module (shared) authn_file_module (shared) authnz_ldap_module (shared) authz_default_module (shared) authz_groupfile_module (shared) authz_host_module (shared) authz_user_module (shared) autoindex_module (shared) cgi_module (shared) dav_module (shared) dav_fs_module (shared) dir_module (shared) env_module (shared) include_module (shared) isapi_module (shared) ldap_module (shared) log_config_module (shared) mime_module (shared) negotiation_module (shared) proxy_module (shared) rewrite_module (shared) setenvif_module (shared) dav_svn_module (shared) authz_svn_module (shared) php5_module (shared) Syntax OK
答案1
您应该在端口 80 上启用虚拟主机:NameVirtualHost *:80
然后<VirtualHost *:80>
删除ServerName jira.otherserver/