Tomcat behind Nginx: how to proxy both HTTP and HTTPS, possibly on non-standard ports? -


description

we're installing application running tomcat 6 behind nginx different clients. of installations http only, https only, somewhere both. 1 of installations has http , https working on non-standard ports (8070 , 8071) due lack of public ips. application @ hand displayed iframe in app.

current behaviour

tomcat redirects https requests http (so nothing displayed in iframe due browser restrictions mixed content).

current configuration

iframe code:

<iframe src="/saiku-ui"> 

tomcat's server.xml:

<connector port="8080" protocol="http/1.1"/> <!-- bit later... --> <valve classname="org.apache.catalina.valves.remoteipvalve"       remoteipheader="x-forwarded-for"       protocolheader="x-forwarded-proto"     /> 

nginx vhost:

server {   listen 80;   listen 443 ssl spdy;    location /saiku-ui {     proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for;     proxy_set_header x-real-ip $remote_addr;     proxy_set_header host $http_host;     proxy_set_header x-forwarded-proto $scheme;     proxy_pass http://saiku-server; # upstream name     proxy_redirect off;   } }  upstream saiku-server {   server ip.of.tomcat.server:8080; } 

desired behaviour

  1. tomcat should listen on 1 single port both http , https requests.

    if there 2 <connector> tags harder configure nginx.

  2. tomcat should not redirect between schemas.

  3. nginx may listen on arbitrary ports (e.g. listen 8071 ssl spdy;).
  4. links, generated tomcat should either relative or include schema, host, , port provided nginx.

additional info

i've tried add schema , proxyport attributes <connector>, after tomcat redirect http https (at least it's better).

i can't google such configuration , not experienced tomcat. please help.

actually want not possible, it's required have 2 separate connector tags , 2 upstreams in nginx, so:

tomcat's server.xml:

<connector port="8080" protocol="http/1.1"            connectiontimeout="20000"            proxyport="80" />  <connector port="8443" protocol="http/1.1"            connectiontimeout="20000"            proxyport="443"            scheme="https" secure="true" /> 

matching nginx configuration:

server {   listen 80;   listen 443 ssl spdy;    location /saiku-ui {     proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for;     proxy_set_header x-real-ip $remote_addr;     proxy_set_header host $http_host;     proxy_set_header x-forwarded-proto $scheme;     proxy_pass http://saiku-server-$scheme; # upstream name, note variable $scheme in     proxy_redirect off;   } }  upstream saiku-server-http {   server     ip.of.tomcat.server:8080; }  upstream saiku-server-https {   server     ip.of.tomcat.server:8443; } 

please note tomcat receives plain http traffic on both 8080 , 8443 ports (no ssl there, it's terminated nginx), connections on 8443 port generate links must start https:// instead of http:// (via attributes scheme="https" secure="true") , insert in links ports, specified in proxyport attribute.

nginx terminate ssl , proxy secure connections 8443 port of tomcat via saiku-server-https upstream, https value of $scheme nginx request variable (see location block)


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -