【发布时间】:2016-08-05 20:02:01
【问题描述】:
最近我得到了一个在 Apache HTTP 服务器和 WildFly 上运行的项目。我对这些技术很陌生。我在 Apache 端的代理配置有问题。这是我的 Apache 的 httpd.conf VirtualHosts 配置。
#frontend
<VirtualHost *:80>
<Location />
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Location>
ServerName adminapp.pl
DocumentRoot "D:\Projects\RS_front\adminapp"
ErrorLog "d:\logs\httpd\admin_error.log"
RewriteEngine On
RewriteCond %{REQUEST_URI} !^(/index\.html|/img|/js|/css|/assets|/robots\.txt|/favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</VirtualHost>
#backend proxy
<VirtualHost *:80>
<Location />
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Location>
ServerName api.adminapp.pl
ErrorLog "d:\logs\httpd\wildflyProxy.log"
CustomLog "d:\logs\httpd\wildflyProxy_custom.log" combined
ForensicLog "d:\logs\httpd\wildflyProxy_forensic.log"
DumpIOInput On
DumpIOOutput On
LogLevel Debug
ProxyRequests Off
ProxyPreserveHost On
#adres aplikacji and serwerze Wildfly
ProxyPass "/" "http://localhost:8080/adminapp/" timeout=600
ProxyPassReverse "/" "http://localhost:8080/adminapp/" timeout=600
ProxyPassReverseCookiePath "/adminapp" "/"
Header add Access-Control-Allow-Origin: adminapp.pl
Header add Access-Control-Allow-Headers "X-Requested-With,Content-Type,Authorization,Accept,Content-Disposition"
Header add Access-Control-Allow-Methods "GET,PUT,POST,DELETE,PATCH,OPTIONS"
</VirtualHost>
我尝试通过 adminapp 登录系统,但它不起作用。我对此感到完全不知所措,因为我无法跟踪任何错误或日志来告诉我此配置有什么问题。
这是我目前跟踪的内容(地址 adminapp.pl 和 api.adminapp.pl 在我的 hosts 文件中映射到 localhost):
在登录尝试时应调用的 URL 类似于 http://localhost:8080/adminapp/oauth/token。当我在浏览器中输入此 url 时,我收到 WildFly 服务器的响应,我提供了错误的登录凭据和 WildFly 服务器日志异常。
当我在浏览器中输入 url http://api.adminapp.pl/oauth/token 时,我会从服务器得到相同的响应。所以看起来代理工作正常。
当我尝试通过 adminapp.pl 登录时,提供了错误的凭据以实现相同的错误,但没有任何反应。我在 Apache 访问日志“POST /api.adminapp.pl/oauth/token HTTP/1.1”200 906”中只得到这一行。
当我将前端配置为 adminapp.pl 以直接连接到 http://localhost:8080/adminapp(无代理)时,WildFly 服务器记录了错误且凭据错误。但是前面还有其他问题“XMLHttpRequest 无法加载http://localhost:8080/adminapp/oauth/token。请求的资源上不存在'Access-Control-Allow-Origin'标头。因此不允许访问Origin'http://localhost'。”。我猜这是 CORS 引起的,所以我的配置中需要代理。
正如您从我的配置中看到的那样,我尝试生成尽可能多的日志,但我找不到更多有用的信息。似乎Apache在内存中缓冲日志并按时间间隔将它们转储到文件中?有没有办法告诉 Apache 在收到信息后立即记录信息?
总结一下,我需要设置此代理,但不知道如何进一步解决我的问题。你能告诉我我该怎么做吗?
问候
【问题讨论】: