Here are the preconditions:
- I've registered domain
example.com
in godaddy. - I run a Tomcat on
8080
port with a couple of applications. 8080 port is hidden to the world. - I want to map
subdomain.example.com
toserver:8080/subdomain
. I want it be possible to do similar mappings (subdomain2.example.com
toserver:8080/anotherContext
, for example) in the future. example.com
should be mapped toserver:8080/mainPageApp
- All other applications should be accesible via their context:
example.com/app
->server:8080/app
.
For now, I've only configured godaddy (I do not know if this is good):
Can you help me with nginx config for this case? Here is mine, but it sends infinite redirects:
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html;
}
}
server {
listen 80;
server_name subdomain.localhost;
location / {
proxy_pass http://127.0.0.1:8080/subdomain;
}
}