WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Why does my website return a private address? (29 posts)

  1. 3bx
    Member
    Posted 2 years ago #

    Hello,

    I have just finished a successful WordPress installation on a local ubuntu server vm. In the general settings area I have this: http://10.0.101.101:5580 I have also modified Apache2 ports.conf and the sites-available default file so the website works on port 5580. I also have a firewall configured with a one to one translation so the outside address public address A.B.C.D:5580 gets translated to 10.0.101.101:5580

    When I put A.B.C.D:5580 into a browser the WordPress site main page does come up, so I know the translation is working, but when I try to navigate off the main page it does not work and the browser ends up showing a "could not connect" with for example this in the browser address bar: http://10.0.101.101:5580/?p=13#comments

    This is different behavior than local browsing, where everything works.

    Why is the web site returning the private address?

    Anyone know what kind of changes I need to make to get navigation off the main page working from outside the local network?

    Thanks,
    Greg

  2. s_ha_dum
    Member
    Posted 2 years ago #

    If you are going to use the outside address, you need to always use the outside address. That includes posts and site configuration-- wp-admin->Settings-General. If that local address shows up anywhere in the html/css/javascript of the site the browser is going to look for content on a local network-- the browser's local network, not the network local to the server (though I would expect it to work if you are browsing from the same network. I don't know what to make of that at this point)

  3. 3bx
    Member
    Posted 2 years ago #

    Thanks for your input.

    Let me restate the problem. My new WordPress installation works fine on the local network. I have a firewall that translates the local address of the website to a public outside address. I can successfully access the website from the outside with the translated outside address, but only the main page works. When I navigate off the main page I get a "could not connect" message in the browser and the address that one moment earlier had been the correct public address, now shows up as the translated private address that I have configured in the Site and WordPRess Address section of the General settings.

  4. ClaytonJames
    Member
    Posted 2 years ago #

    I think the issue might be as s_ha_dum describes. If you want your site to be completely accessible from the WAN, you may need a domain name (or external ip) in your WordPress addresses in general settings, rather than an address in the private ip range. The internal ip address will work fine for access within the LAN, but will probably always break when accessed from the WAN.

  5. s_ha_dum
    Member
    Posted 2 years ago #

    ... now shows up as the translated private address that I have configured in the Site and WordPRess Address section of the General settings.

    That is your problem. "View source" on the page that works and I bet you see that private address in there somewhere. As I said, you need to use that external address everywhere, including in General Settings, if you are going to access this from outside the LAN.

  6. 3bx
    Member
    Posted 2 years ago #

    ClaytonJames and s_ha_dum, I appreciate the help, Thanks!

    I just changed the General Settings Site and WordPress Address section to localhost instead of the static local address of the server interface or the translated outside address configured on the firewall.

    So the site still works locally.

    When I first accessed the site remotely after making this change I got only the "It Works!" page and not my WordPress site. To solve this I changed the name of the index.html file in /var/www to paused_index.html. Now when I access my site from the public internet using the public translated address, the main WordPress page comes up successfully, but again...any navigation off the main page results in a "can't connect" web page for http://localhost:5580/wp-login.php

    s_ha_dum I did a source view of the working main page like you mentioned, and you are right it shows the exact information you put in the WordPress and Site Address section of the General Settings. I've included the output below.

    I'm pretty sure I cant put the translated public address in the WordPress and Site Address section and still have the website work locally, that's why I used localhost instead.

    <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width" />
    <title>3BX | Making ways to know..</title>
    <link rel="profile" href="http://gmpg.org/xfn/11" />
    <link rel="stylesheet" type="text/css" media="all" href="http://localhost:5580/wp-content/themes/twentyeleven/style.css" />
    <link rel="pingback" href="http://localhost:5580/xmlrpc.php" />
    <!--[if lt IE 9]>
    <script src="http://localhost:5580/wp-content/themes/twentyeleven/js/html5.js" type="text/javascript"></script>
    <![endif]-->
    <link rel="alternate" type="application/rss+xml" title="3BX » Feed" href="http://localhost:5580/?feed=rss2" />
    <link rel="alternate" type="application/rss+xml" title="3BX » Comments Feed" href="http://localhost:5580/?feed=comments-rss2" />
    <link rel="EditURI" type="application/rsd+xml" title="RSD" href="http://localhost:5580/xmlrpc.php?rsd" />
    <link rel="wlwmanifest" type="application/wlwmanifest+xml" href="http://localhost:5580/wp-includes/wlwmanifest.xml" />
    <meta name="generator" content="WordPress 3.4.1" />
    	<style type="text/css">.recentcomments a{display:inline !important;padding:0 !important;margin:0 !important;}</style>
    </head>
  7. ClaytonJames
    Member
    Posted 2 years ago #

    I am reasonably confident that you just won't have any success serving a WordPress site to the WAN using locahost or an internal ip address in your general settings.

    - using an internal ip address makes it fully accessible only from the LAN,

    - using localhost makes it fully accessible only from the machine where WordPress is installed.

    My best guess on this would be that if you want it to be viewed by the outside world, you either need to use a domain name that resolves to your external ip address, or your numeric external ip address in your URL's in general settings.

    The reasoning here I think, is that if you have localhost in your URL's and I can view your site from another machine, the minute I make a request for any other resource on your site my browser attempts to resolve that address to my own machine (because every machine is localhost) and it will fail.

  8. 3bx
    Member
    Posted 2 years ago #

    Forgot to mention that my wp-config.php file is configured with: DB_HOST as localhost:5580

  9. 3bx
    Member
    Posted 2 years ago #

    ClaytonJames,

    I come from a networking background so it just made no sense to me to configure the outside address on a local machine since the firewall is doing the translations.

    But I took yours (and s_ha_dum's) advice anyway and now it works!

    It seems wrong that I can put an outside public address in the browser bar on a machine behind the firewall and have it work, but hey it works.

    Thanks again for the help, I appreciate it!

  10. ClaytonJames
    Member
    Posted 2 years ago #

    DB_HOST as localhost:5580

    I'm really not sure why you would want to do that. I think by default, mysql requests on ubuntu are restricted to localhost.

  11. 3bx
    Member
    Posted 2 years ago #

    Resolved.

  12. 3bx
    Member
    Posted 2 years ago #

    I changed it back to DB_HOST as localhost without the port. Thanks.

  13. s_ha_dum
    Member
    Posted 2 years ago #

    ... to configure the outside address on a local machine since the firewall is doing the translations.

    The address at wp-admin->Settings->General is the address used by WordPress when generating URLs. That address gets embedded into the markup of the site. Now, think about what is happening. The firewall will translate the request you make to "A.B.C.D" and that works but you get a page with 'localhost' URLs in it. The firewall doesn't translate the URLs in the page. Those just pass through. When you click a a link (from outside your LAN) there is no way your firewall can translate a request to "localhost", or to "10.0.101.101" because those addresses will never get to your firewall at all. The browser doesn't know where it is. In fact, it is being specifically told to look in the wrong place.

    The downside to this is that you are in a sense connecting over the internet every time you connect to your site. Requests are sent just as if you were visiting Google or any other website, though it may only get as far as your ISP's router before turning around.

  14. fonglh
    Member
    Posted 2 years ago #

    It seems wrong that I can put an outside public address in the browser bar on a machine behind the firewall and have it work, but hey it works.

    This happens if your firewall is configured to block loopback connections. Other than that, like s_ha_dum said, it's no different from accessing any other website.

  15. ClaytonJames
    Member
    Posted 2 years ago #

    @fonglh

    This happens if your firewall is configured to block loopback connections.

    I'm definitely not a network guy, but if the goal is to make the site accessible from the WAN, wouldn't this simply be happening because registered domain names resolve to numeric ip addresses which do not include loopback interfaces and address blocks reserved for private internal networks? (As in, you gotta' go out to come back in?)

    In the absence of using a registered domain name, what method other than the static ip address could one use to make the server available from outside the network?

  16. fonglh
    Member
    Posted 2 years ago #

    If the firewall blocks loopback connections, trying to access the external address from the local network wouldn't work. Even though the address resolves to a public IP, the firewall knows the connection originated from within the local network and blocks it.

    I ran into that problem when setting up a test site with dyndns. Other people could see the test site, but I couldn't. That might be why 3bx has the impression that putting your own public address into the browser doesn't work.

  17. 3bx
    Member
    Posted 2 years ago #

    s_ha_dum,

    This statement of yours helps to clear things up for me: "The address at wp-admin->Settings->General is the address used by WordPress when generating URLs"

    I think this helps me understand a new and related problem (so this issue is not totally resolved for me after all...) I'm having.

    My WP blog works perfect now from the outside when I use the public address I put in the Site and WordPress address section of General Settings. The thing is I have purchased a domain from Network Solutions and have used their management tool to associate my domain with the public address of my blog. Now (from the outside) if I put my domain in the browser address bar the main page of my blog comes up fine....but again...if I navigate off the page it doesn't work.

    So the problem here (I think) is the server is sending the url as the static address I configured, but the browser is trying to use a resolvable hostname?

    Wonder how I could fix this? Do I need to edit my /etc/hosts and /etc/hostname file? Then instead of using the static outside address in the general settings use the resolvable hostname of the server (something ClaytonJames mentioned way back in the beginning)?

    Thanks

  18. 3bx
    Member
    Posted 2 years ago #

    Something else I don't understand about installing and self hosting a WordPress blog. When you have a domain like 3bx.us or wordpress.org for example, the actual webserver is a host in the domain, so why isn't the webpage url something like webserver1.wordpress.org instead of just the domain wordpress.org

  19. s_ha_dum
    Member
    Posted 2 years ago #

    This statement of yours helps to clear things up for me: "The address at wp-admin->Settings->General is the address used by WordPress when generating URLs"

    Right. That address is not a configuration value like the DB_HOST value in that it is not used exclusively internally by the software.

    Now (from the outside) if I put my domain in the browser address bar the main page of my blog comes up fine....but again...if I navigate off the page it doesn't work.

    What happens?

    So the problem here (I think) is the server is sending the url as the static address I configured, but the browser is trying to use a resolvable hostname?

    I'm a bit confused. If you give a browser a numeric address it won't even try to resolve it. Usually, you can use the IP and the human-readable name interchangeably.

    Wonder how I could fix this? Do I need to edit my /etc/hosts and /etc/hostname file? Then instead of using the static outside address in the general settings use the resolvable hostname of the server (something ClaytonJames mentioned way back in the beginning)?

    You should be able to use the resolvable hostname, full stop. And you need to or you will get a mix of hostname/IP URLs on your site. Editing /etc/hosts/ on the server will prevent unnecessary outside requests but that is a convenience for you. It shouldn't effect how things work. At least that is my working theory... :)

  20. 3bx
    Member
    Posted 2 years ago #

    What happens is strange. There are no errors, just nothing happens. At the bottom of the browser window I can see where the action is supposed to happen, but it just doesn't.

    For example if I try a new post I see: (public adress)A.B.C.D:5580/wp-admin/post-new.php at the bottom of the browser...but it just sits there, nothing happens. For fun I recursively chmoded everything in /var/www to 777 to see if that was a problem, but didn't help.

    Some website actions actually do work though. I can click on the Sample Page and it works and I can leave a reply on a post and it works...

    If the server is up you can see for yourself at 3bx.us

  21. s_ha_dum
    Member
    Posted 2 years ago #

    Your URLs are all numeric and all have the :5580 suffix. However, the parts that I can see all seem to work. I can't get to your backend, obviously :)

  22. 3bx
    Member
    Posted 2 years ago #

    Right :) But if you click on Log in you should at least get the Username / Password page though right? And that doesn't come up if you access the page with 3bx.us whereas it does if you access the page with the public address:5580 you see when you inspect the source.

  23. s_ha_dum
    Member
    Posted 2 years ago #

    That login page is weird.

    <html><head><title>3BX.US</title><meta name="keywords" content=""</head><frameset rows="100%", *" border="0" frameborder="0"><frame src="http://76.93.148.234:5580" name="3BX.US"></frameset></html>

    What did you do to it? Why is it in a frame like that? And why is it in a frame with the wrong address? Your login page, which works, is here: http://76.93.148.234:5580/wp-login.php

  24. 3bx
    Member
    Posted 2 years ago #

    I didn't make any changes. No idea about the frame. 76.93.148.234 is the right address, it's my outside address. 3bx.us will resolve to 205.178.189.131 if you ping it from the command line, but that is network solutions and they forward it to 76.93.148.234...

    If I access the website as 3bx.us then right click the Log in link to open in a new tab it works, and as expected the browser bar turns into the address instead of the domain, because that is what I told the WP server to send. If I just click on the Log in link from the main 3bx.us page it doesn't work.

    Seems like I'm going to have to figure out how to configure my server with a domain name that I can put in the WordPress and Site Address section of the General Settings. Which brings me back to the question I had earlier. I don't think I can put 3bx.us into the WordPress and Site Address section because that is a domain, not a server. Or maybe I can? Why is it that the website address in the browser bar is wordpress.org instead of, for example, webserver1.wordpress.org since obviously there is a server. I'm thinking it is because that part is taken care of by apache.

  25. 3bx
    Member
    Posted 2 years ago #

    Is there a way to make the dashboard changes by editing config files? I changed the WordPress and Site Address to 3bx.us and as I expected it broke the site.

    I am going to restore from a backup vm, but was wondering if there is a way to reverse or make GUI Dashboard changes from the command line.

    Thanks

  26. s_ha_dum
    Member
    Posted 2 years ago #

    I don't think I can put 3bx.us into the WordPress and Site Address section because that is a domain, not a server. Or maybe I can?

    I can't think of any reason you can't do that. When you punch in "google.com" that is a domain, not a server, yet Google's servers handle it just fine. That is what DNS is all about. It is no different from when you set up any other site. You put in the domain, not the IP, as a general rule.

  27. 3bx
    Member
    Posted 2 years ago #

    I'm pretty sure I know a solution. I buy a static IP from my ISP then create a DNS A record with Network Solutions for something like webserver1.3bx.us matched to the purchased IP address. Then on my WP server, I configure it to return "webserver1.3bx.us" to the "hostname --fqdn" command. After that I can properly put "http://webserver1.3bx.us" in the WordPress and Site Address section of General Settings and things will work.

    I believe I was mixing up the web forwarding that I have now with the creation of an new A record for my WP server.

  28. fonglh
    Member
    Posted 2 years ago #

    Is there a way to make the dashboard changes by editing config files? I changed the WordPress and Site Address to 3bx.us and as I expected it broke the site.

    http://codex.wordpress.org/Changing_The_Site_URL

  29. 3bx
    Member
    Posted 2 years ago #

    Ok, I more or less solved the problem with all of your help. Thanks!

    I turned off all my web forwarding at Network Solutions for my domain, 3bx.us, and I configured one DNS A record as such: hisdev1.3bx.us to equal 76.93.148.234

    Then on my server I put "dns-domain 3bx.us" in the /etc/resolvconf/resolv.conf.d/base file and added "dns-domain 3bx.us" to my /etc/network/interfaces file and added to the /etc/hosts file the line: "10.0.101.101 hisdev1.3bx.us hisdev1"

    Then in the Dashboard General Settings for WordPress and Site Address I put: "hisdev1.3bx.us:5580"

    Now from the inside or outside my website works perfectly by putting "hisdev1.3bx.us:5580" in the browser. If I had a different firewall I wouldn't need to use port 5580, but the SSG5 reserves 80 for itself.

    I consider this to be resolved because I can now view my site locally and from the outside. To make this work I learned I needed three things:

    1. The local WordPress server must be configured to know its own fully qualified domain name. You can verify this with the command "hostname --fqdn"
    2.You must get a DNS A record with the fully qualified domain name of the server (from part 1) and your public IP known to the global DNS.
    3. You must put that same fully qualified domain name from part 1 and 2 in the in the WordPress and Site Address section of the General Settings.

    That's about it :)

Topic Closed

This topic has been closed to new replies.

About this Topic