LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > CentOS
User Name
Password
CentOS This forum is for the discussion of CentOS Linux. Note: This forum does not have any official participation.

Notices


Reply
  Search this Thread
Old 08-07-2017, 08:37 AM   #1
Sefid par
Member
 
Registered: Jul 2013
Location: Iran, Shiraz
Distribution: Ubuntu
Posts: 131

Rep: Reputation: 26
apache VirtualHost not accessible from outside


I have two questions.
I'm trying to create a VirtualHost on VPS with CentOS 7.
I've created a file eset.lo.conf in sites-available:
Code:
'/etc/httpd/sites-available/eset.lo.conf'
and linked to it in
Code:
'/etc/httpd/sites-enabled/eset.lo.conf'.
Also added the line
Code:
IncludeOptional sites-enabled/*.conf
to httpd.conf
and added the hostnames in /etc/hosts:
Code:
<IP> eset.lo www.eset.lo
the eset.lo.conf is like this:
Code:
<VirtualHost *:80>
	ServerName eset.lo
	ServerAlias eset.lo *.eset.lo
	DocumentRoot "/var/www/html/eset"
	<Directory /var/www/html/eset/>
		AllowOverride All
		Options All
		#Order allow,deny
		Allow from all
		Require all granted
	</Directory>
</VirtualHost>
also added the index.html in /var/www/html/eset with content:
Code:
"Hello, Here is html/eset"
Now, This site is available in VPS itself when I do curl:
Code:
curl http://eset.lo/
output:
Hello, Here is html/eset

Ok.
When I also do 'curl http://localhost/'
I get the same output: Hello, Here is html/eset

And the next question is:
I want to access this VHost from my personal computer. I've added it's IP to my /etc/hosts:
Code:
<IP> est.lo www.est.lo
But it's not accessible. The 'curl -v http://eset.lo/' is:
Code:
curl -v http://eset.lo/
*   Trying <IP>...
* TCP_NODELAY set
* Connected to eset.lo (<IP>) port 80 (#0)
> GET / HTTP/1.1
> Host: eset.lo
> User-Agent: curl/7.54.1
> Accept: */*
> 
* Recv failure: Connection reset by peer
* Closing connection 0
curl: (56) Recv failure: Connection reset by peer
and when I open the IP of VPS, I get the same output again:
Hello, Here is html/eset.

What's wrong with my configuration?
And why localhost inherited VirtualHost configuration?

Last edited by Sefid par; 08-07-2017 at 08:42 AM.
 
Old 08-07-2017, 10:54 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,165
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
Ok.
When I also do 'curl http://localhost/'
I get the same output: Hello, Here is html/eset

And the next question is:
<snip>
and when I open the IP of VPS, I get the same output again:
Hello, Here is html/eset.

What's wrong with my configuration?
And why localhost inherited VirtualHost configuration?
For both your questions:
If you have defined only one vhost, then that's also the default one, so vising your webserver either as localhost, or by its IP, you will get the default vhost, that in your case is eset.lo
 
1 members found this post helpful.
Old 08-07-2017, 11:00 AM   #3
Sefid par
Member
 
Registered: Jul 2013
Location: Iran, Shiraz
Distribution: Ubuntu
Posts: 131

Original Poster
Rep: Reputation: 26
Thanks a lot. But, When I call "eset.lo" from my computer, Although I've binded the host and IP in /etc/hosts, Why I don't get access to the VHost? It's output is nothing as I shown in 'curl':
Quote:
Originally Posted by Sefid par View Post
Code:
curl -v http://eset.lo/
*   Trying <IP>...
* TCP_NODELAY set
* Connected to eset.lo (<IP>) port 80 (#0)
> GET / HTTP/1.1
> Host: eset.lo
> User-Agent: curl/7.54.1
> Accept: */*
> 
* Recv failure: Connection reset by peer
* Closing connection 0
curl: (56) Recv failure: Connection reset by peer
 
Old 08-07-2017, 11:34 AM   #4
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,165
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
Thanks a lot. But, When I call "eset.lo" from my computer, Although I've binded the host and IP in /etc/hosts, Why I don't get access to the VHost? It's output is nothing as I shown in 'curl':
As you noted in your OP, the problem goes away when you "open" the IP in VPS. So I guess it's a firewall problem.
Quote:
and when I open the IP of VPS, I get the same output again:
Hello, Here is html/eset.
 
Old 08-07-2017, 12:41 PM   #5
Sefid par
Member
 
Registered: Jul 2013
Location: Iran, Shiraz
Distribution: Ubuntu
Posts: 131

Original Poster
Rep: Reputation: 26
Excuse me. I told badly. I meant when I open IP using browser. I've set the firewall rule before configure the VHost, And port 80 was open when the problem occurred.
 
Old 08-07-2017, 01:40 PM   #6
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,165
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
Originally Posted by Sefid par View Post
Excuse me. I told badly. I meant when I open IP using browser. I've set the firewall rule before configure the VHost, And port 80 was open when the problem occurred.
Anyway, it's a networking problem, not an apache one.
 
Old 12-29-2017, 12:29 AM   #7
nejnej25
Member
 
Registered: Dec 2017
Location: Asia
Distribution: Slackware 14.2,CentOS 7, Ubuntu, Debian
Posts: 116

Rep: Reputation: Disabled
You need to buy the domain name you want for your VPS. In your example is www.eset.lo so the DNS server can reach your VPS thru a domain name.

domain name mapping inside /etc/hosts is good for local use and pings.
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Apache VirtualHost's Dreft Linux - Server 1 12-16-2010 02:55 PM
[SOLVED] Apache VirtualHost Help Chris1989 Linux - Server 6 11-08-2009 05:30 PM
Apache virtualhost with 2 ip's djroy Linux - Newbie 2 10-12-2009 01:48 PM
Apache -VirtualHost davidhk Debian 7 08-19-2005 12:33 PM
Apache and VirtualHost's slowrider Linux - Networking 0 03-17-2002 12:09 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > CentOS

All times are GMT -5. The time now is 10:33 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration