Detailed description of the implementation of Nginx+Tomcat to achieve single IP, multi-domain name, multi-site access
Detailed description of the implementation of Nginx+Tomcat to achieve single IP, multi-domain name, multi-site access
Foreword:
Recently, I helped my friend to build two websites with a very small budget. As small as two websites can only run on a public network server with 512m memory (tomcat+MySQL, because the memory is too small, only two websites can be deployed on the same tomcat), each website has its own domain name, preliminary consideration is to use nginx as a reverse proxy to map the two domain names to the corresponding application. So there is the configuration problem on the title "nginx multi-domain list server single IP single Tomcat different applications". I won't say much about the nonsense introduced by Nginx. Post the configuration file here for your reference:
The configuration file for the domain name A:www.a.com is as follows:
Server {listen 80; server_name * .a.com; location / {proxy_pass http://localhost:8080/projectA/; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;}}
The configuration file for the domain name B:www.b.com is as follows:
Server {listen 80; server_name * .b.com; location / {proxy_pass http://localhost:8080/projectB/; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;}}
The above is an example of Nginx+Tomcat to achieve single IP, multi-domain name, multi-site access, if you have any questions, please leave a message or go to the community to exchange and discuss, thank you for reading, hope to help you, thank you for your support!