We have the following set-up: several subdomains lead to the same server, which is running nginx as a proxy to each of them. All subdomains are currently used for testing features in development, so their content is more or less identical.
This is more or less how each nginx site configuration file looks like
server {
listen 80;
server_name full.web.address;
location / {
proxy_pass http://devhost:8080;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_cache global;
proxy_cache_valid 200 302 600m;
proxy_cache_valid 404 1m;
}
location /robots.txt {
alias /var/www/default/robots.txt;
}
}
server {
listen 443;
server_name full.web.address;
location / {
proxy_pass http://devhost:8080/;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto https;
proxy_cache global;
proxy_cache_valid 200 302 600m;
proxy_cache_valid 404 1m;
}
location /robots.txt {
alias /var/www/default/robots.txt;
}
ssl on;
ssl_certificate /etc/nginx/combined.crt;
ssl_certificate_key /etc/nginx/cert.key;
ssl_session_timeout 5m;
ssl_protocols SSLv2 SSLv3 TLSv1;
}
devhost or whichever happens to be, is set in /etc/hosts by a script on reboot. We have three Tomcat 7 servers running right now and in all of their web.xml files we have the following:
<security-constraint>
<web-resource-collection>
<web-resource-name>Confidential resources</web-resource-name>
<url-pattern>/manager/*</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>
CONFIDENTIAL
</transport-guarantee>
</user-data-constraint>
</security-constraint>
Every server.xml has the same:
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
URIEncoding="UTF-8" />
<Engine name="Catalina" defaultHost="full.web.address">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>
<Host name="full.web.address" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Valve className="org.apache.catalina.valves.RemoteIpValve"
remoteIpHeader="x-forwarded-for"
remoteIpProxiesHeader="x-forwarded-by"
protocolHeader="x-forwarded-proto"
/>
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
</Engine>
They also use the same WAR file. I actually copied everything and just changed the names and IP addresses. The problem is, in one of them it goes to https://full.web.address/manager/ without a problem, on the others it goes on an infinite redirect loop to itself. The settings and content are identical.