tujiorg Posted November 29, 2019 Posted November 29, 2019 Hi Team, I have deployed a java war file developed on spring boot and spring security. All URLs are working fine as those URLs are not secured by spring security. But one URL i.e. tujiorg.com/tujiorg/profile which is secured by spring security is redirecting to http://127.0.0.1:8080/tujiorg_tujiorg/login . Can you please help me on it. WAR file is working fine on localhost. URL http://localhost:8080/tujiorg/profile is redirecting to http://localhost:8080/tujiorg/login so user can login. Can you please check from where this 127.0.0.1:8080/tujiorg_tujiorg comes into picture. Thanks and Regards,Rishabh Kabra
wolstech Posted November 29, 2019 Posted November 29, 2019 So a few things...first, be aware that the folder name tujiorg_tujiorg is the correct name. Our server adds username_ to all war filenames if it's missing before deploying them. Many war files don't like being renamed, so when building your war, be sure to build the war file with the username_ already added to the name.As for redirecting to localhost, does the war try to assume the domain from the request? Apache acts as a proxy here, and connects to your app on port 8080 to get content. You can also see what happens when your app is accessed directly by using http://tommy.heliohost.org:8080/tujiorg_tujiorg/ to get to it.
tujiorg Posted November 30, 2019 Author Posted November 30, 2019 War is getting context path. I am not much aware about Apache and proxies. I tried to fix it from Java side but nothing worked. Can you please help me on solve it. Can it be possible that Apache sends my domain to application instead of localhost. I have found something on internet but don't know if it will work.<VirtualHost *:443>ServerName www.myapp.orgProxyPass / http://127.0.0.1:8080/RequestHeader set X-Forwarded-Proto httpsRequestHeader set X-Forwarded-Port 443ProxyPreserveHost On... (SSL directives omitted for readability)</VirtualHost> If you think that anything else can be done from server side to fix it please do it and if you know that how to fix it from java side please let me know. And thanks a lot for quick response.
wolstech Posted November 30, 2019 Posted November 30, 2019 This is a common issue around here, and it's always fixed in the Java code. 99% of the issues are related to not naming the war file with the username_ on it before you deploy it. Other than that, I know people have had issues with the context path before (the way our system works causes it to guess wrong on what this is). I would start by rebuilding your war, naming the output file tujiorg_tujiorg.war. Then upload and deploy that file. That fixes most people's issues with this. If that doesn't help, you'll need to check your code to ensure you're using relative links. You don't want the code to include the domain name when generating links (because it can and will get the domain name wrong, resulting in links to localhost...). If I remember right there's also a way to force the context path by setting an attribute in one of the XML files, but I don't know Java much at all and might be mistaken.
tujiorg Posted November 30, 2019 Author Posted November 30, 2019 Okay. I will try with naming convention for WAR file. Hope, It will get solve soon. Thanks for this information and quick responses.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now