create an alias for `localhost:8080/` as `www.my-domain.com/`

14,453

Solution 1

You can add a /etc/hosts entry like the following:

127.0.0.2   my-domain.com

Make sure to use a lo address unused before.

Then you add an iptables rule to redirect the traffic incoming into 127.0.0.2:8080 to 127.0.0.1:80.

iptables -t nat -A OUTPUT -d 127.0.0.2 -p tcp --dport 80 -j REDIRECT --to-port 8080

Solution 2

For doing this on firefox, you can install the Redirector add-on. After installing, restart firefox and then go to Tools > Add-ons > Redirector > Preferences.

Click on "New Redirect...". And in the "Include Pattern" field add www.my-domain.com/ or whatever you want the redirection to occur from. And in the "Redirect to" field, add localhost:8000. Type www.my-domain.com/ in the "Example URL" field and click "Test pattern" if you want to confirm it works. If you see this:

redirection successful

You will be able to type www.my-domain.com/ to go to localhost:8000.

Share:
14,453

Related videos on Youtube

Rajat Gupta
Author by

Rajat Gupta

A problem solver & enthusiastic programmer looking out for exciting work opportunities. Highly interested in building Android applications, Web development, & Server side coding involving (sql/ nosql) databases & APIs. I love solving problems, building efficient approaches & algorithms. To describe my strong points, I have pretty decent problem solving skills, fast learner & highly motivated & energetic person! Gained good experience in software development in the past 2 years working on numerous android & web development projects with companies like olready.in, twowaits.com, spactre.com. Selected among Top three finalists for LinkedIn MTV GetAJob Season 4 for Flipkart as Software Developer Intern among 50k candidates.

Updated on September 18, 2022

Comments

  • Rajat Gupta
    Rajat Gupta almost 2 years

    In ubuntu, I want to create an alias for localhost:8080/ as www.my-domain.com/. So that whenever I type www.my-domain.com/ in URL field, it shows up from localhost:8080/. What is the easiest way to set this up ? Is there any application that could just do this mapping?

    In windows, I used to use Fiddler2 to achieve the same goals.

    • jobin
      jobin over 10 years
      Do you want this to be browser-independent?
    • saiarcot895
      saiarcot895 over 10 years
    • jobin
      jobin over 10 years
      @saiarcot895: No its not! The OP has given an example for localhost, its not how to rename it.
    • Rajat Gupta
      Rajat Gupta over 10 years
      @Jobin: Preferably yes, but browser dependent may also be acceptable.
    • Rajat Gupta
      Rajat Gupta over 10 years
      @saiarcot895: I also had a look to that question earlier but the answer there doesn't work for port forwarding..
  • Rajat Gupta
    Rajat Gupta over 10 years
    anything similar for chrome as well ?
  • Rajat Gupta
    Rajat Gupta over 10 years
    oops .. that is a redirect solution, not an alias.. sorry I didn't wanted this..
  • jobin
    jobin over 10 years
    @user01: How exactly would it matter?
  • jobin
    jobin over 10 years
    @user01: Did you have a look at the link posted by saiarcot895: askubuntu.com/questions/26386/renaming-localhost?
  • Rajat Gupta
    Rajat Gupta over 10 years
    actually it does.. I use domain as alias for localhost while in developemnt mode