1

I need to redirect port :80 to :8080/ui. I know iptables lets you redirect :80 to :8080 but it doesn't accept the URL part, only the port. How should I do it?

It is acceptable to change the URL to :8080/ui (URL changing is OK). I can't use Tomcat AJP because I use websockets which is not supported.

Apache proxying doesn't work with websockets so it is not an option.enter code here

5
  • Just to be sure: you want the browser to keep the :80 URL, right? (So some forwarding/proxying invisible to the user.) And are you sure "It is acceptable" is not missing the word "not"?
    – Arjan
    Mar 21, 2015 at 15:53
  • @Arjan Its ok if the url changes, I'm not missing the "not" word. Thanks for clarification.
    – adam0404
    Mar 21, 2015 at 16:06
  • 1
    Okay... Now that you're fine with exposing Tomcat to the internet directly: did you consider just running it on port 80 then (or use iptables for that part, if you're on Unix and don't want to run Tomcat with root privileges), and deploy the "ui" context to the root? Or use Apache's proxying, stackoverflow.com/questions/17649241/…
    – Arjan
    Mar 21, 2015 at 16:46
  • @Arjan I didn't even realize I could run tomcat on :80 :D Thanks for the tip. Apache proxying doesn't work with websockets so it is not an option. I will run it on :80 I think.
    – adam0404
    Mar 21, 2015 at 17:15
  • Did you read the Stack Overflow link in my previous comment? Web sockets should work nicely with proxying, I think.
    – Arjan
    Mar 22, 2015 at 7:35

2 Answers 2

2

Is running a web server on port 80 (to send the redirect) acceptable? If not, it won’t work anyway.

I’ll go with Apache, since you already mention it in the tags. In your httpd.conf (or include file in sites or whatever), add the following line either to the top level configuration or the appropriate virtual host:

Redirect permanent / http://1.2.3.4:8080/ui

This requires mod_alias to be installed and enabled, which it likely is by default anyway.

0
1

Another way of achieving this is using a webpage on the server to redirect to your desired webpage as well (use this in combination with your iptables firewall rule change).

<meta http-equiv="refresh" content="0; url=http://example.com/" />

https://stackoverflow.com/questions/5411538/redirect-from-an-html-page

http://en.wikipedia.org/wiki/URL_redirection

1
  • 1
    This is only a last-resort solution because everything else is simply better.
    – Daniel B
    Mar 21, 2015 at 16:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.