Proxying from nginx to Jetty

Posted by newbie on Server Fault See other posts from Server Fault or by newbie
Published on 2011-10-04T12:48:37Z Indexed on 2012/04/11 23:32 UTC
Read the original article Hit count: 371

Filed under:
|
|
|

I'm proxying request from nginx to Jetty, but I have problem with request that Jetty receives. Jetty requests shows that request IP address is 127.0.0.1. But I want real server IP and my site has multiple domains, so when request is coming from some domain name to my server, it must available in Jetty request too.

nginx config:

server {

    listen   80; ## listen for ipv4
    listen   [::]:80 default ipv6only=on; ## listen for ipv6

    server_name  localhost;

    access_log  /var/log/nginx/localhost.access.log;

    location / {
        proxy_pass  http://127.0.0.1:8080;
        proxy_set_header  X-Real-IP  $remote_addr;
    }
}

Servlet request:

Dump Servlet
getMethod:  GET
getContentLength:   -1
getContentType:     null
getRequestURI:  /dump/info
getRequestURL:  http://127.0.0.1:8080/dump/info
getContextPath:     
getServletPath:     /dump
getPathInfo:    /info
getPathTranslated:  /tmp/jetty-0.0.0.0-8080-test.war-_-any-/webapp/info
getQueryString:     null
getProtocol:    HTTP/1.0
getScheme:  http
getServerName:  127.0.0.1
getServerPort:  8080
getLocalName:   127.0.0.1
getLocalAddr:   127.0.0.1
getLocalPort:   8080
getRemoteUser:  null
getUserPrincipal:   null
getRemoteAddr:  127.0.0.1
getRemoteHost:  127.0.0.1
getRemotePort:  50905
getRequestedSessionId:  6ubs42zhm5q61k5hm84ni3ib
isSecure():     false
isUserInRole(admin):    false
getLocale:  en_US
getLocales:     en_US
getLocales:     en

© Server Fault or respective owner

Related posts about linux

Related posts about debian