Jump to content

[Solved] domain redirects to 127.0.0.1:8080


tujiorg

Recommended Posts

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

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.org
ProxyPass / http://127.0.0.1:8080/
RequestHeader set X-Forwarded-Proto https
RequestHeader set X-Forwarded-Port 443
ProxyPreserveHost 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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...