Issue
I have one Cloud Server and 2 domain.
I have one success but second domain not working.
working conf;
server {
listen 80;
listen [::]:80;
server_name www.fromthepast.org fromthepast.org;
access_log /var/log/nginx/fromthepast-access.log main;
error_log /var/log/nginx/fromthepast-error.log;
location / {
proxy_set_header Host $host:$proxy_port;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://localhost:8080/;
}
}
You can see enter the website fromthepast.org its working correct.
wrong conf
server {
listen 80;
listen [::]:80;
server_name www.suyla.org suyla.org;
access_log /var/log/nginx/suylaaccess.log main;
error_log /var/log/nginx/suyla-error.log;
location / {
proxy_set_header Host $host:$proxy_port;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://localhost:8080/denizhan;
}
}
actually its working but not correct.
you can see enter suyla.org > redirect http://suyla.org:8080/denizhan
i dont want :8080 port, just suyla.org or suyla.org/denizhan
How can i do multi domain config NGINX with tomcat ?
Solution
i fixed it. example;
/etc/nginx/conf.d
server {
listen 80;
listen [::]:80;
server_name www.suyla.org suyla.org;
access_log /var/log/nginx/suyla-access.log main;
error_log /var/log/nginx/suyla-error.log;
location / {
proxy_set_header Host $host:$proxy_port;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://localhost:8082/;
}
}
and redirejct 8082
one more config > ../tomcat/conf/server.xml
<Service name="denizhan">
<Connector port="8082" protocol="org.apache.coyote.http11.Http11NioProtocol"
connectionTimeout="20000"
redirectPort="8444" />
<Engine name="Catalina" defaultHost="localhost">
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Context path="" docBase="/opt/tomcat/webapps/denizhan" reloadable="false" useHttpOnly="true">
<Manager pathname=""/>
</Context>
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_accessss_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
</Engine>
</Service>
if i want one more domain and app, i will redirect 8083, thankx for all
Answered By - streji