Apache ist das Front-End meiner Web-App, dann verwende ich mod_rewrite, um die Anfrage an JBoss zu übertragen. Bisher klingt das ziemlich normal, aber das Problem, das ich habe, ist: wenn ich die App Zugriff direkt über Jboss @http://localhost:8080/app/page?raw=foo%26bar&page=1
:Apache/mod_rewrite> Tomcat-Codierung% 26 und "&"
request.getParameter("raw") = foo&bar
Wenn ich die App über Apache zugreifen @http://localhost/foo%26bar&page=1
request.getParameter("raw") = foo
So Irgendwo auf dem Weg ist die %26
verloren und durch eine &
ersetzt, die die rohe Variable hackt.
Dies ist meine Apache Rewrite-Regel.
RewriteRule ^/(.*) \
http://localhost:8080/app/home?raw=$1 [L,P]
Das Protokoll Apache Zugriff zeigt: http://localhost/foo%26bar&page=1
Und das Rewrite-Protokoll zeigt: http://localhost:8080/app/home?raw=foo&bar&page=1
Aber ich sein möchte die Anfrage: http://localhost:8080/app/home?raw=foo%26bar&page=1
Ich bin ziemlich sicher, dass dies der Fall ist auch mit Schrägstrichen /
zu mir auch dies ist eine Art von Codierung Problem. Gibt es eine Möglichkeit, die URL unverändert zu übernehmen? Ich kann mir das nicht vorstellen.
EDIT:
Das erste, was ich sagen möchte, ist danken Ihnen zu Gumbo für mich einige sehr gute Vorschläge geben! Aufgrund dieser Vorschläge habe ich meine Apache-Konfiguration zu Testzwecken vereinfacht.
Dies ist, wie es aussieht:
ServerRoot "C:/apps/xampplite/apache"
Listen 80
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule log_config_module modules/mod_log_config.so
ServerAdmin [email protected]
ServerName localhost:80
DocumentRoot "C:/apps/xampplite/htdocs"
ErrorLog "logs/error.log"
LogLevel debug
DefaultType text/plain
<IfModule log_config_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
<IfModule logio_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
</IfModule>
CustomLog "logs/access.log" combined
</IfModule>
RewriteEngine On
RewriteLog "C:/apps/xampplite/apache/logs/rewrite.log"
RewriteLogLevel 9
RewriteMap escape int:escape
RewriteRule ^/(.*) http://localhost:8080/app/home?raw=${escape:$1} [L,P]
Hier sind die Schritte Ich nahm: Starten Sie Apache, gehen Sie zu
http://localhost/foo%26bar&page=1
in meinem Web-Browser, stoppen Apache.
Zugriffsprotokolleinträge:
::1 - - [15/Mar/2010:19:17:18 -0400] "GET /foo%26bar&page=1 HTTP/1.1" 403 224 "-" "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6"
Rewrite-Log-Einträge:
::1 - - [15/Mar/2010:19:17:18 --0400] [localhost/sid#54d160][rid#5e1360/initial] (2) init rewrite engine with requested uri /foo&bar&page=1
::1 - - [15/Mar/2010:19:17:18 --0400] [localhost/sid#54d160][rid#5e1360/initial] (3) applying pattern '^/(.*)' to uri '/foo&bar&page=1'
::1 - - [15/Mar/2010:19:17:18 --0400] [localhost/sid#54d160][rid#5e1360/initial] (5) map lookup OK: map=escape key=foo&bar&page=1 -> val=foo&bar&page=1
::1 - - [15/Mar/2010:19:17:18 --0400] [localhost/sid#54d160][rid#5e1360/initial] (2) rewrite '/foo&bar&page=1' -> 'http://localhost:8080/app/home?raw=foo&bar&page=1'
::1 - - [15/Mar/2010:19:17:18 --0400] [localhost/sid#54d160][rid#5e1360/initial] (3) split uri=http://localhost:8080/app/home?raw=foo&bar&page=1 -> uri=http://localhost:8080/app/home, args=raw=foo&bar&page=1
::1 - - [15/Mar/2010:19:17:18 --0400] [localhost/sid#54d160][rid#5e1360/initial] (2) forcing proxy-throughput with http://localhost:8080/app/home
Fehlerprotokolleinträge:
[Mon Mar 15 19:16:56 2010] [notice] Apache/2.2.12 (Win32) configured -- resuming normal operations
[Mon Mar 15 19:16:56 2010] [notice] Server built: Jul 22 2009 11:35:54
[Mon Mar 15 19:16:56 2010] [notice] Parent: Created child process 2324
[Mon Mar 15 19:16:56 2010] [debug] mpm_winnt.c(487): Parent: Sent the scoreboard to the child
[Mon Mar 15 19:16:57 2010] [notice] Child 2324: Child process is running
[Mon Mar 15 19:16:57 2010] [debug] mpm_winnt.c(408): Child 2324: Retrieved our scoreboard from the parent.
[Mon Mar 15 19:16:57 2010] [info] Parent: Duplicating socket 148 and sending it to child process 2324
[Mon Mar 15 19:16:57 2010] [info] Parent: Duplicating socket 140 and sending it to child process 2324
[Mon Mar 15 19:16:57 2010] [debug] mpm_winnt.c(605): Parent: Sent 2 listeners to child 2324
[Mon Mar 15 19:16:57 2010] [debug] mpm_winnt.c(564): Child 2324: retrieved 2 listeners from parent
[Mon Mar 15 19:16:57 2010] [notice] Child 2324: Acquired the start mutex.
[Mon Mar 15 19:16:57 2010] [notice] Child 2324: Starting 64 worker threads.
[Mon Mar 15 19:16:57 2010] [notice] Child 2324: Starting thread to listen on port 80.
[Mon Mar 15 19:16:57 2010] [notice] Child 2324: Starting thread to listen on port 80.
[Mon Mar 15 19:17:18 2010] [error] [client ::1] attempt to make remote request from mod_rewrite without proxy enabled: proxy:http://localhost:8080/app/home
[Mon Mar 15 19:17:52 2010] [notice] Parent: Received shutdown signal -- Shutting down the server.
[Mon Mar 15 19:17:52 2010] [notice] Child 2324: Exit event signaled. Child process is ending.
[Mon Mar 15 19:17:52 2010] [info] Child 2324: Accept thread exiting.
[Mon Mar 15 19:17:53 2010] [notice] Child 2324: Released the start mutex
[Mon Mar 15 19:17:53 2010] [info] Child 2324: Accept thread exiting.
[Mon Mar 15 19:17:53 2010] [info] Child 2324: 64 threads blocked on the completion port
[Mon Mar 15 19:17:54 2010] [notice] Child 2324: All worker threads have exited.
[Mon Mar 15 19:17:54 2010] [notice] Child 2324: Child process is exiting
[Mon Mar 15 19:17:54 2010] [notice] Parent: Child process exited successfully.
[Mon Mar 15 19:17:54 2010] [info] removed PID file C:/apps/xampplite/apache/logs/httpd.pid (pid=1424)
Interessanterweise ist der erste Eintrag in dem Zugriffsprotokoll zeigt das% 26 und es ist im ersten Eintrag des Rewrite-Protokolls verschwunden.
Noch verwirrt von diesem ...
Ich versuchte: RewriteRule ^/(. *) \ http : // localhost: 8080/app/home? roh = $ 1 [NE, L, P] Kein Glück, der Eintrag zum Überschreiben ist der gleiche wie ohne NE-Flag. Vielleicht ist die Flagge an der falschen Stelle? – user293479
Das sah vielversprechend aus, aber immer noch kein Glück. Ich erhöhte die Protokollebene in Apache/Rewrite und etwas entdeckt ... Die erste Zeile wie folgt aussieht: init Motor umschreiben mit angeforderten uri/foo & bar & page = 1 Bedeutet das nicht, dass wir bereits mit einem Arbeits manipulierte Zeichenfolge? Sollte es nicht noch sein:/foo% 26bar & page = 1 an dieser Stelle? Weiteres in den Protokollen können wir das Entkommen sehen: Karte Nachschlag OK: map = escape key = foo & Bar & page = 1 -> val = foo & bar & page = 1 aber es scheint nichts zu sein, zu tun, weil das% 26 bereits umgesetzt wurde &. – user293479
@ user293479: Verwenden Sie andere Regeln? – Gumbo