Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm running a web server (Ubuntu) on my local home network. I'm behind a router. On the WAN I have a direct IP. When not on my home network and accessing my website via the WAN direct IP my website displays correctly and everything works.

On my home LAN behind the router, accessing my website via the WAN direct gets me to my router's admin login page. This is normal. But...

Accessing my website (via it's home LAN IP address) from another computer on my home LAN gets me to the website but the layout display is broken and clicking on any link takes me to the WAN direct IP (my router's Admin login page).

How can i get my website to display properly and the links to work when accessing it from my home LAN?

share|improve this question

migrated from Mar 20 '11 at 9:41

This question came from our site for professional and enthusiast programmers.

I need more info then that. What's your domain name? Is it in a folder over LAN? What links break? – tylermwashburn Mar 19 '11 at 21:50

Check your CSS and JavaScript URLs. You may have to switch them from relative to absolute links, since it sounds like the URL routing is different based on how you try to access the site.

The easiest way to do this is to look at the resources that the browser is attempting to load by using Firebug or Developer tools (The Resources Tab). Verify that your stylesheets are being loaded properly (You should be able to select them and view the content). If they are not their, or you get an error on the resources tab, then check the URL that the browser is looking at and make sure that it is the right URL.

I would be willing to bet that your browser is looking for stylesheets at your LAN IP address, but it should be looking to the WAN IP address.

share|improve this answer
The LAN IP address is used nowhere in the website for the simple reason that the person who created the website is remote. He accesses the web server via WAN and he doesn't know my LAN IP address. – Tokyo Dan Mar 21 '11 at 21:27

Your router isn't doing "hairpin NAT" correctly. Lots of cheap home gateways have buggy NAT code that doesn't do this right.

It sounds like you've already got your router's port mapping (a.k.a. "port forwarding") or DMZ (a.k.a. "default host", "bastion host", etc.) feature set up correctly, since from the WAN side of the router, when you point a browser at the public WAN IP address of the router, you get the page from your web server.

But if you're on your internal network, when you connect to the public WAN IP address of your router, you should still get your web server's page, not your router's admin page. If your router wants to serve up its admin page when you connect to port 80 on its NAT private IP address, that's fine. But not on the public WAN IP address.

When you're on a client on the private side of the NAT and try to access the web server directly via its NAT private IP address, it may load the first HTML file just fine based on a URL like "", but when the browser goes to load the CSS file and images, it probably forms URLs like "", which means the public WAN IP address of your router, which because of your buggy router means your router's administration web server is intercepting those requests itself, and it doesn't have those resources, so stuff breaks.

share|improve this answer
From my LAN (behind the firewall) When I go to the WAN IP I get the router admin page. When I go to the LAN IP address of the server I get the index page but the layout is all screwed up. And hyperlinks don't work. – Tokyo Dan Mar 21 '11 at 21:33
@Tokyo Dan Yes, I understood that. That's exactly the situation that my answer applies to. You should NOT get the router's admin page when you go to the router's WAN IP from LAN. You should still get your server just as you would from outside your network. The fact that you get your router's admin page means that it's not doing NAT hairpinning correctly. – Spiff Mar 22 '11 at 4:44

You need relative links rather than absolute links. So instead of something like this in your html:

<link rel="stylesheet" type="text/css" href="" />
<img src="" alt="Some Image" />

You need it to look like this:

<link rel="stylesheet" type="text/css" href="/mysite.css" />
<img src="/images/someimage.png" alt="Some Image" />
share|improve this answer
This may help a little bit, but he wouldn't have to do it if his router did hairpin NAT correctly. If he goes this "make all links relative" route, he'll also have to reconfigure his web server redirect/rewrite rules. For instance, the default install of Apache on my OS will redirect ""; to ""; (oops, Markdown ate the http:// in those) just for leaving off the trailing "/", and a redirect like that would run afoul of his broken NAT gateway again. – Spiff Mar 23 '11 at 2:10
Where do I look or what settings do I check in my Router to make sure I even have the haipin NAT setup correctly? – Tokyo Dan Mar 23 '11 at 11:17

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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