Reputation: 2955
We have a Java app serving multiple products. It's behaviour changes based on the product.
The product is defined by the subdomain of the url:
https://<product1>.example.com
https://<product2>.example.com
...
Each of these urls is mapped to a distinct AWS Elastic Load Balancer via Route 53, which forwards the requests to our fleet of homogenous EC2 App Servers.
So https://<product1>.example.com
has an ELB, https://<product2>.example.com
has a different ELB. Both of these ELBS direct traffic to the same set of servers with the same Java app however.
The ELB's forward requests via ports 9443 and 9001 based on whether they are https or not, and nginx does a redirect for all traffic on port 9001, otherwise it is forwarded via port 8080 to the Java app.
I need to be able to determine what the original url was before it reaches the Java app, so it can be used to determine the configuration and behaviour of the response. The best I've come up with is $http_referer
, but that only works for any requests after the initial visit, we need the url on the first visit as well.
Below is a (very) rough diagram of our deployment, I hope it helps.
Upvotes: 3
Views: 147
Reputation: 2955
Turns out the full hostname does get pushed to the nginx layer. Modifying the logging of nginx I added $host
and the full hostname appeared. Issue I am having is tomcat losing the host data, but that should be easily remedied.
Here is what I updated in nginx.conf
:
log_format main '$host $remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
Notice the $host
variable at the very front of block after main
.
Upvotes: 0