在不同的子域上一起运行Apache和Tomcat?
在ServerFault上发布此内容但没有得到回复。 希望我能在Ubuntu网站上获得更好的运气。
我一直试图让这一切在今天全面运作。 我有一个解析到域example.com的服务器。 这是运行Apache2和Tomcat 6. 要求是将对example.com的请求指向apache2,将app.example.com指向Tomcat。 我知道我必须为此工作执行VirtualHost代理传递。 以下是我服务器上的设置。
/ etc / hosts文件看起来像这样
127.0.0.1 localhost localhost.localdomain example.com app.example.com
我在/ etc / apache2 / sites-enabled中有两个用于不同域的虚拟主机文件
/etc/apache2/sites-enabled/example.com看起来像这样
# Admin email, Server Name (domain name) and any aliases ServerAdmin webmaster@localhost ServerName example.com ServerAlias www.example.com DocumentRoot /var/www Options FollowSymLinks AllowOverride None Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all ErrorLog /var/log/apache2/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog /var/log/apache2/access.log combined Alias /doc/ "/usr/share/doc/" Options Indexes MultiViews FollowSymLinks AllowOverride None Order deny,allow Deny from all Allow from 127.0.0.0/255.0.0.0 ::1/128
/etc/apache2/sites-enabled/app.example.com文件看起来像这样
ServerName app.example.com ServerAlias www.app.example.com ProxyPreserveHost On ProxyPass / http://localhost:8080/ ProxyPassReverse / http://localhost:8080/ SetEnv force-proxy-request-1.0 1 SetEnv proxy-nokeepalive 1
mod_proxy和mod_rewrite都在apache实例上启用。 我有example.com和app.example.com的CNAME条目。 访问app.example.com时,我收到403禁止,说我无法访问服务器上的/。 我究竟做错了什么?
当我在虚拟主机定义中使用这样的构造时,我有类似的问题:
ProxyPass / http://localhost:8080/ ProxyPassReverse / http://localhost:8080/
在我的情况下,当我指向应用程序时它开始工作:
-
这些允许您重定向此类地址: http : //app.example.com/confluence
ProxyPass /confluence/ http://localhost:8180/confluence/ ProxyPassReverse /confluence/ http://localhost:8180/confluence/
-
这些允许您将这样的地址重定向: http : //app.example.com到正确的应用程序
ProxyPass / http://localhost:8180/confluence/ ProxyPass / http://localhost:8180/confluence/
尝试:
VirtualHost 'app.example.com:80'
代替
VirtualHost '*:80'