톰켓 proxypass 시에 header 에 Original URI 전달하기.
관련해서 proxy backend 로 넘겨줄 때 X-Original-URI 말고 X-forwarded-URI 로도 넘겨주는 방법(동일?) 선택하면 될듯합니다.
참고 : http://nerds.qminderapp.com/request-url-behind-proxy.html
nginx 설정
header 의 X-Original-URI
location / {
proxy_set_header X-Original-URI $request_uri;
proxy_pass http://127.0.0.1:8080/;
}
location /testuri {
proxy_set_header X-Original-URI $request_uri;
proxy_pass http://127.0.0.1:8080/;
}
java 설정
request.getHeader(“X-Original-URI”);
실제 패킷 분석 결과
(톰켓으로 넘어가는 loopback 8080 캡쳐 : # tcpdump –i lo –qexX port 8080)
get http://test.hongstalk.com
09:54:56.618161 00:00:00:00:00:00 (oui Ethernet) > 00:00:00:00:00:00 (oui Ethernet), IPv4, length 623: localhost.47502 > localhost.webcache: tcp 557
0x0000: 4500 0261 210a 4000 4006 198b 7f00 0001 E..a!.@.@…….
0x0010: 7f00 0001 b98e 1f90 7f44 b41a 86a9 4ace ………D….J.
0x0020: 8018 0200 0056 0000 0101 080a 4fc9 9511 …..V……O…
0x0030: 4fc9 9511 4745 5420 2f20 4854 5450 2f31 O…GET./.HTTP/1
0x0040: 2e30 0d0a 582d 4f72 6967 696e 616c 2d55 .0..X-Original-U
0x0050: 5249 3a20 2f0d 0a48 6f73 743a 2031 3237 RI:./..Host:.127
get http://test.hongstalk.com/testuri
09:58:54.909510 00:00:00:00:00:00 (oui Ethernet) > 00:00:00:00:00:00 (oui Ethernet), IPv4, length 543: localhost.47504 > localhost.webcache: tcp 477
0x0000: 4500 0211 f02b 4000 4006 4ab9 7f00 0001 E….+@.@.J…..
0x0010: 7f00 0001 b990 1f90 59d0 c7ce 9d52 e649 ……..Y….R.I
0x0020: 8018 0200 0006 0000 0101 080a 4fcd 37e4 …………O.7.
0x0030: 4fcd 37e4 4745 5420 2f20 4854 5450 2f31 O.7.GET./.HTTP/1
0x0040: 2e30 0d0a 582d 4f72 6967 696e 616c 2d55 .0..X-Original-U
0x0050: 5249 3a20 2f74 6573 7475 7269 0d0a 486f RI:./testuri..Ho