“Invalid URI in request” trying to proxy iframe co

2019-07-04 16:33发布

I'm trying to debug a problem in a page that contains an iframe. The site serving the parent page is code I'm working on that I can easily run locally, but the content of the iframe comes from code I don't have access to. There's some protection blocking cross-domain iframing, which won't be a problem in production, because there they'll run on the same domain. However, I need to debug something locally, so I'm using Apache to proxy the site.

Also, the internal network I'm on uses a proxy which Apache has to take into account.

My apache config so far: (note that I totally suck at apache configuration)

RewriteEngine on
RewriteRule ^/(.+)\.aspx(.*)$   https://www.example.com/$1.aspx$2   [PT,L]
RewriteRule ^/(.+)\.aspx$   https://www.example.com/$1.aspx   [PT,L]
RewriteRule ^/static/(.+)$   https://www.example.com/static/$1   [PT,L]
RewriteCond  %{SERVER_PORT} !^8080$ 
RewriteRule ^(.*) http://%{SERVER_NAME}:8080%{REQUEST_URI} [P,L]


#SSLProxyEngine On
ProxyRequests On
ProxyRemote http://www.example.com http://pac.group.intranet:8080
ProxyRemote https://www.example.com http://pac.group.intranet:8080

The aspx and /static/ stuff is the other site that I'm trying to proxy here. My own site is running on port 8080.

I'm currently getting a Invalid URI in request on a request that looks totally normal. At some point it seemed to be accepting my request, then it complained about SSL, so I added SSLProxyEngine On. It's currently off, which doesn't generate a SSL error, so clearly the problem occurs before that.

After I added SSLProxyEngine On, it basically worked except that I wasn't proxying the static resources for the other site yet. So I added the /static/ line, and then I got my current problem.

I've spent way too much time on this already and I just can't figure it out. I can't find any clear examples or tutorials explaining how to do this. It seems like such an obvious thing to do, but I just can't get it working. But removing it now won't fix it. Basically, Apache seems to act totally unpredictably. I don't understand this well enough to understand why.

Any idea what's causing this problem and how to finally get it working?

I'm using XAMPP 3.2.1 on Windows.

Log details:

[Thu Jun 19 14:25:38.879301 2014] [ssl:warn] [pid 3248:tid 220] AH01909: RSA certificate configured for www.example.com:443 does NOT include an ID which matches the server name
[Thu Jun 19 14:25:38.924310 2014] [core:warn] [pid 3248:tid 220] AH00098: pid file C:/Workset/tools/xampp/apache/logs/httpd.pid overwritten -- Unclean shutdown of previous Apache run?
[Thu Jun 19 14:25:39.262377 2014] [ssl:warn] [pid 3248:tid 220] AH01909: RSA certificate configured for www.example.com:443 does NOT include an ID which matches the server name
[Thu Jun 19 14:25:39.309387 2014] [mpm_winnt:notice] [pid 3248:tid 220] AH00455: Apache/2.4.4 (Win32) OpenSSL/0.9.8y PHP/5.4.19 configured -- resuming normal operations
[Thu Jun 19 14:25:39.309387 2014] [mpm_winnt:notice] [pid 3248:tid 220] AH00456: Server built: Feb 23 2013 13:07:34
[Thu Jun 19 14:25:39.309387 2014] [core:notice] [pid 3248:tid 220] AH00094: Command line: 'c:\\workset\\tools\\xampp\\apache\\bin\\httpd.exe -d C:/Workset/tools/xampp/apache'
[Thu Jun 19 14:25:39.310387 2014] [mpm_winnt:notice] [pid 3248:tid 220] AH00418: Parent: Created child process 7668
[Thu Jun 19 14:25:40.066538 2014] [ssl:warn] [pid 7668:tid 232] AH01909: RSA certificate configured for www.example.com:443 does NOT include an ID which matches the server name
[Thu Jun 19 14:25:40.441613 2014] [ssl:warn] [pid 7668:tid 232] AH01909: RSA certificate configured for www.example.com:443 does NOT include an ID which matches the server name
[Thu Jun 19 14:25:40.489623 2014] [mpm_winnt:notice] [pid 7668:tid 232] AH00354: Child: Starting 150 worker threads.
[Thu Jun 19 14:25:43.904305 2014] [core:error] [pid 7668:tid 1680] [client ::1:56999] AH00126: Invalid URI in request GET /foo/search/welcome.aspx?ask=bar HTTP/1.1
[Thu Jun 19 14:26:00.705665 2014] [core:error] [pid 7668:tid 1680] [client ::1:57001] AH00126: Invalid URI in request GET /foo/search/welcome.aspx?ask=bar HTTP/1.1

标签: apache proxy
1条回答
Emotional °昔
2楼-- · 2019-07-04 17:07

I finally got it working, and I'm sharing the solution here for posterity:

ProxyPassMatch ^(/.+)\.aspx(.*)$   https://www.example.com$0
ProxyPass /static    https://www.example.com/
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/

SSLProxyEngine On
ProxyRequests On
ProxyRemote http://www.example.com http://pac.group.intranet:8080
ProxyRemote https://www.example.com http://pac.group.intranet:808

It's actually much cleaner this way. Not relying on rewrite rules and using ProxyPassMatch for the regexp is basically the core of the solution.

查看更多
登录 后发表回答