Fedora Linux Support Community & Resources Center

Go Back   FedoraForum.org > Fedora 17/18 > Servers & Networking
FedoraForum Search

Forgot Password? Join Us!

Servers & Networking Discuss any Fedora server problems and Networking issues such as dhcp, IP numbers, wlan, modems, etc.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 1st August 2008, 08:13 PM
dmbyer Offline
Registered User
 
Join Date: Feb 2007
Location: Eagan, Minnesota
Age: 28
Posts: 100
[SOLVED] Apache improperly redirecting to localhost

I am setting up a web server to run a few sites, including a blog (wordpress). I am using a straight default installation of Apache, PHP, and MySql. The only thing I have done for configuration is disable SELinux (at least for now, since it was causing me problems until I am more comfortable configuring it) and change the wordpress config file (detailed below).

Directly from phpinfo() running (named index.php under root directory, /var/www/html) are some important settings you may want to know:
System: localhost.localdomain 2.6.25.11-97.fc9.i686
Virtual Directory Support: disabled
Apache Version: Apache/2.2.8 (Fedora)
Hostname/Port: localhost.localdomain:0
HTTP_HOST: 76.17.222.27
SERVER_NAME: 76.17.222.27
SERVER_ADDR: 192.168.0.100

I see that SERVER_ADDR is set to the machine's IP on the LAN, so I am wondering if that is having an effect on it? I am worried though that if I change settings like that to point to the external IP, scripts running on the server will make requests out to the ISP then bounce back rather than just accessing straight on the machine.

The behavior, is that when I enter the address in my web browser from a remote location (feel free to access this too http://76.17.222.27/wordpress/) it begins to execute something, but then the next request the browser makes is to 192.186.0.100 which obviously is not going to work (but does when I am on my LAN).

Does anyone have any ideas or suggestions on this? I'm fairly new to administration, but am fairly savvy. Research has turned up little to nothing on this issue.

I also want to note that my wp-config.php (wordpress configuration) has a setting for the host, and it was set to localhost, but when changed to my external IP, the results are the same (even after a reboot). The setting is currently set to:
define('DB_HOST', '76.17.222.27'); // was 'localhost' with same results
__________________
http://dmbyer.boldlygoingnowhere.org/
Asus P5LD2 Motherboard, Intel Core 2 Duo, 2GB Corsair RAM, Creative EMU-II 12-12m, ATi 2600XT.

Last edited by dmbyer; 2nd August 2008 at 05:27 PM.
Reply With Quote
  #2  
Old 2nd August 2008, 08:51 AM
marcrblevins's Avatar
marcrblevins Offline
Registered User
 
Join Date: Jun 2006
Location: Texas
Age: 42
Posts: 4,168
For my wordpress, the only thing I changed in /etc/wordpress/wp-config.php was my login info for the database, nothing else. If I type in 'localhost/wordpress in Firefox, it automatically changed to 'kiriyamablevins.dyndns.org/workpress' on the fly. No harm there.

The only thing that comes to play with Apache is:
Code:
[marc@kiriyamablevins conf]$ diff httpd.conf.original httpd.conf
264c264
< #ServerName www.example.com:80
---
> ServerName kiriyamablevins.dyndns.org:80
Go ahead name your rig and use some dns like www.dyndns.org to point to your rig with your supplied static IP address. You can use dynamic IP address and use ddclient with dyndns.
Reply With Quote
  #3  
Old 2nd August 2008, 03:49 PM
dmbyer Offline
Registered User
 
Join Date: Feb 2007
Location: Eagan, Minnesota
Age: 28
Posts: 100
Thanks for the reply. I checked my httpd.conf and saw I had not set the servername, so I changed it to my external IP (since I am not set up with dns yet) and uncommented the line. I then restarted the service, and attempted to connect again (this is with also using my external IP in the wp-config). It hung up trying to connect to my external IP now for some reason. It eventually gave me an error:
Quote:
Error establishing a database connection.
Next, I changed the wp-config to use 'localhost' for the hostname, and tried again. It at least worked this time, but only because I am now on my LAN. It is still redirecting the IP to 192.168.0.100.

Do I need to configure my hostnames in some way in /etc/hosts? Perhaps add some sort of new hostname that points to my external IP and use that for Apache and wordpress?

Currently, the only thing I see there (/etc/hosts) is the localhost entry pointing at 127.0.0.1. I am a bit confused, because in the browser, I am being redirected to 192.168.0.100, indicating it is acquiring an IP from somewhere else (not the hostname), otherwise it would be connecting to 127.0.0.1. It seems to be looking right at the ethernet device, which is why I am concerned it is a problem with Apache (I can't see PHP code using anything other than hostnames or hard IPs).

Thanks for your help!

EDIT:
Just realized that if it is redirecting to an external IP address, then the request is boucing out and coming back. SQL does not use port 80 (and this is where it's failing, hence the database connection error). I have my firewall up which would be blocking that. I am going to try disabling the firewall to see if the issue resolves.

EDIT:
Unfortunately disabling the firewall did not help, so still back to square one.
__________________
http://dmbyer.boldlygoingnowhere.org/
Asus P5LD2 Motherboard, Intel Core 2 Duo, 2GB Corsair RAM, Creative EMU-II 12-12m, ATi 2600XT.

Last edited by dmbyer; 2nd August 2008 at 04:00 PM.
Reply With Quote
  #4  
Old 2nd August 2008, 04:37 PM
dmbyer Offline
Registered User
 
Join Date: Feb 2007
Location: Eagan, Minnesota
Age: 28
Posts: 100
Resolved

Ok, I believe I have this solved, though technically I have not tried it from an external IP address. I went in to the WordPress Settings, and found a section for your blog URL. It was set to 192.168.0.100. I changed it to my external IP address, and now it works (and keeps the external IP in the address bar).

So, theoretically, this should be working externally now.

Steps for resolution:
Ensure Wordpress has the external IP/Domain name for the site URL
Ensure Apache ServerName directive is set to the external IP/Domain name
Ensure wp-config.php has localhost set for the SQL Host location

Steps for prevention:
RTFM
__________________
http://dmbyer.boldlygoingnowhere.org/
Asus P5LD2 Motherboard, Intel Core 2 Duo, 2GB Corsair RAM, Creative EMU-II 12-12m, ATi 2600XT.
Reply With Quote
  #5  
Old 23rd September 2008, 04:45 AM
geeksdatabase Offline
Registered User
 
Join Date: Feb 2007
Posts: 1
dmbyer,

Thanks alot. You saved my day. The solution worked for me. Even though I didn't understand the solution completely. I really appreciate your post.

RTFM:
I don't know if there is any manual that explains this. Let me know where you found this information. That might help me in my future experiments.
Reply With Quote
  #6  
Old 23rd September 2008, 07:21 AM
icydog Offline
Registered User
 
Join Date: Nov 2005
Posts: 447
If Apache's UseCanonicalName directive is on, then Apache will redirect requests that it gets to the ServerName of the appropriate server.
Reply With Quote
Reply

Tags
apache, improperly, localhost, redirecting

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Redirecting Apache Mysql etc. seabird Servers & Networking 6 4th February 2009 12:51 AM
Apache & SSL - localhost.localdomain? savage Servers & Networking 10 13th December 2005 08:04 PM
How to change apache email address apache@localhost to admin@proporta.lk niloshima Servers & Networking 2 17th November 2005 11:36 AM
apache@localhost.com pannet1 Servers & Networking 4 9th November 2005 10:46 PM
No localhost: Apache misconfigured? llanitedave Servers & Networking 6 23rd January 2005 03:03 AM


Current GMT-time: 01:57 (Friday, 24-05-2013)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat