I have a Spring Boot application deployed in a VPS. I packaged it as a
war and deployed it through the Tomcat manager (
It works if I access the endpoints by using the VPS' IP, such as
http://<IP>:<Tomcat port>/api/login. However, it doesn't work if I access it by the domain name, such as
http://example.com:<Tomcat port>/api/login. More specifically, I get
(failed) net::ERR_CONNECTION_TIMED OUT in the Network tab of Chrome Developer Tools.
By other means I know the domain is correctly pointing to the VPS' IP. I searched around and tried the following solutions:
- Configure reverse proxy via Apache;
localhostby the domain name everywhere;
- Change the request domain in a Spring filter.
But none of these worked.
I also tried the nginx solution from the linked question, but it seems to me that nginx never worked on this VPS, as it fails
nginx -t with the setup that came with the VPS.
Since I have a React app also being deployed by this VPS, I think making Tomcat use port 80 is not an option.
Since I'm not finding any other solution, what can I do?
Update 1: forgot to add
apachectl -S output as per the description of apache-2.4 (anonymized):
[Fri Sep 21 13:42:06.248978 2018] [proxy_html:notice] [pid 29712] AH01425: I18n support in mod_proxy_html requires mod_xml2enc. Without it, non-ASCII characters in proxied pages are likely to display incorrectly. VirtualHost configuration: <VPS IP>:8080 example.com (/home/<user>/conf/web/example.com.apache2.conf:1) ServerRoot: "/etc/apache2" Main DocumentRoot: "/var/www/html" Main ErrorLog: "/var/log/apache2/error.log" Mutex fcgid-pipe: using_defaults Mutex watchdog-callback: using_defaults Mutex proxy-balancer-shm: using_defaults Mutex rewrite-map: using_defaults Mutex fcgid-proctbl: using_defaults Mutex ssl-stapling: using_defaults Mutex proxy: using_defaults Mutex ssl-cache: using_defaults Mutex default: dir="/var/run/apache2/" mechanism=default Mutex mpm-accept: using_defaults PidFile: "/var/run/apache2/apache2.pid" Define: DUMP_VHOSTS Define: DUMP_RUN_CFG User: name="www-data" id=33 Group: name="www-data" id=33
Update 2: the React app stopped working. I followed the advice of
nginx -t, fixed it, restarted it and it started working again. There's a chance I broke something related to that while trying to implement reverse proxy, so probably disregard the above comment about.
Update 3: also forgot about attempt to change Spring's filter.