I have just done a clean install of apache on RedHat. In the httpd.conf file, I have changed the ServerName to the IP address of the computer. From the command line, when I use xdg-open I cannot view the test page from the apache server (when using the public IP in the address bar), however I can see it when I open 127.0.0.1.
I have a rule in my firewall to allow traffic on port 80.
Is there a way to debug this?
for your firewall, you can check the current rule with
/etc/init.d/iptables status command.
and you can disable/cleanup your iptables with
/etc/init.d/iptables stop
to check the route to your public ip ,do tracepath YOUR-PUBLIC-IP
Related
Inside the box, I have two virtual hosts:
<VirtualHost *:80>
HostName my.site1
...
</Virtualhost *:80>
<VirtualHost *:80>
HostName my.site2
...
</VirtualHost>
How can I connect to the vhosts inside the guest from the host? In my (host) /etc/hosts I have:
127.0.0.1 my.site1
127.0.0.1 my.site2
Because of the Vagrant's port mapping, the guest is accessible only as my.site1:port, e.g., my.site:3000. With that, the Apache inside the guest takes me just to the root (the Apache's welcome site). It is the same for both vhosts: my.site1:3000 and my.site2:3000.
apachectl -S logs:
VirtualHost configuration:
*:80 is a NameVirtualHost
default server stretch.localdomain (/etc/apache2/sites-enabled/000-default.conf:1)
port 80 namevhost stretch.localdomain (/etc/apache2/sites-enabled/000-default.conf:1)
port 80 namevhost my.site1 (/etc/apache2/sites-enabled/001-site1.conf:1)
port 80 namevhost my.site2 (/etc/apache2/sites-enabled/002-site2.conf:1)
Is that because of improper configuration of vhosts or am I missing some point in the name/port or host/guest configuration?
Am I right it should work this way?
my.site1:3000 -> contents of my.site1
my.site2:3000 -> contents of my.site2
Okay, so the problem here is the networking. I was able to reproduce this problem. First of all, please disable the port forwarding in Vagrant. Just comment config.vm.network "forwarded_port", guest: 80, host: 8070 and do a vagrant reload .To get this working, you need to check your host's IP address and then go to your Vagrant file and edit config.vm.network "private_network", ip: "X.X.X.X" so that the ip address here is actually on the same network as your host. What I did is just incremented the last octet by 1. e.g. My local IP address is 192.168.23.45 so I assigned 192.168.23.46 to the Vagrant guest.
Once this is done, perhaps, you can save yourself all the trouble by just using this shell script to create Virtual hosts for yourself. I have pasted the output below which you can go through to see that I have setup my two virtual hosts with mysite1 and mysite2 names.
Then just put the host file entries on your host like below:
192.168.23.46 mysite1
192.168.23.46 mysite2
And accessing the website using http://mysite1 and http://mysite2. You might want to change the content of the index.php placed by script under the respective document roots so that you can be sure that the requests are being handled by correct virtual hosts since this scripts just deals with the default index.php of apache which will be found under both your document roots.
The other option is to make the Vagrant box available on public network and then
access it using the public IP and for that, you will have to enable config.vm.network "public_network" in your Vagrant file and the rest of the process of creating the Virtual host is the same (Using this script).
[root#localhost vagrant]# bash test.sh
Enter the server name your want (without www) : mysite1
Enter a CNAME (e.g. :www or dev for dev.website.com) : mysite1
Enter the path of directory you wanna use (e.g. : /var/www/, dont forget the /): /var/www/mysite1/
Enter the user you wanna use (e.g. : apache) : apache
Enter the listened IP for the server (e.g. : *): *
Web directory created with success !
/etc/httpd/conf.d/mysite1.conf
Virtual host created !
Would you like me to create ssl virtual host [y/n]?
n
Testing configuration
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message
Syntax OK
Would you like me to restart the server [y/n]?
y
Redirecting to /bin/systemctl restart httpd.service
======================================
All works done! You should be able to see your website at http://mysite1
Share the love! <3
======================================
Wanna contribute to improve this script? Found a bug? https://gist.github.com/mattmezza/2e326ba2f1352a4b42b8
[root#localhost vagrant]# bash test.sh
Enter the server name your want (without www) : mysite2
Enter a CNAME (e.g. :www or dev for dev.website.com) : mysite2
Enter the path of directory you wanna use (e.g. : /var/www/, dont forget the /): /var/www/mysite2/
Enter the user you wanna use (e.g. : apache) : apache
Enter the listened IP for the server (e.g. : *): *
Web directory created with success !
/etc/httpd/conf.d/mysite2.conf
Virtual host created !
Would you like me to create ssl virtual host [y/n]?
n
Testing configuration
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message
Syntax OK
Would you like me to restart the server [y/n]?
y
Redirecting to /bin/systemctl restart httpd.service
======================================
All works done! You should be able to see your website at http://mysite2
Share the love! <3
======================================
Wanna contribute to improve this script? Found a bug? https://gist.github.com/mattmezza/2e326ba2f1352a4b42b8
Please let me know in case you need more clarification.
I am not sure how or if this can be done. I have a home network and would like to see a computer,not the server, via a remote location. I have Apache on my server. Example: the network computers I would like to see ip 152.254.1.33. Is there a way to add this ip to Apache root directory? I have tried to add a shortcut with in the root directory and it only works on the home network, will not via remote connection.
I need some clarification here on what you are trying to acomplish, are you trying to access the Apache website outside of the local network?
If that is the case, Apache is automatically set to listen on all network interfaces, you can check this in your virtual host configuration in the sites-enabled directory of your apache installation.
You should see something like in the 000-default.conf
You can test if apache is serving pages up correctly using the command
curl 127.0.0.1
You should see the HTML of the page being served.
If this is the case, then it's likely the firewall on your machine/router or your ISP is blocking the required ports. You can allow Apache through the firewall on Ubuntu using sudo ufw allow Apache Full
If you give me some more info in comments we can probably work this out.
I'm running apache through a clean Ubuntu server VM on Parallels for Mac. I have it set up following this tutorial
But when I try to access it from my mac, I get no response. Ping returns a response, but not viewing the page in chrome.
Here is my vhost file ccminecraft.com.conf
I also tried putting in
192.168.1.108 ccminecraft.com
192.168.1.108 www.ccminecraft.com
into my hosts file on my mac, but that didn't work. nslookup returns that it's searching on google's DNS, which both my mac and router are configured to use. But shouldn't it be going to 192.168.1.108 instead of doing a DNS lookup?
Try telneting the port 80 on your ip#
telnet 192.168.1.108 80 if it doesn't respond you need to reconfigure your firewall or disable it.
service iptables stop
systemd --> systemctl stop firewall
Before usig DNS try with ip# so in :
ServerName put yout_ip# if it works you need to disble the adapter that link you to the internet and just let VM adapter enabled
I have a jboss server and an apache web server on the same machine. Jboss has to stay listening on port 80, so I had to switch which port apache listened on. Before, when it was listening on port 80, everything worked fine. I set up a virtual host for a website I'm working on, and I was able to use the URL for that site as a I defined it in the virtual host file and my hosts file (I'm using Windows). After I changed the port it listened on, I get the following error:
Problem loading page: Unable to connect
I've restarted the server, restarted my machine, changed the port to several different numbers that weren't being used for anything else, and I even tried changing the localhost IP address from 127.0.0.1 to 127.0.0.2 to see if that would help, but none of this has worked. I changed the port in both httpd.conf and httpd-vhosts.conf, but nothing has really worked. I checked the IP address for the site with ping, and it showed that I'm using the right one. I would really appreciate some help because nothing is working.
Likely a local firewall issue. You should only need to change Listen, ServerName and <virtualhost>. You can use lsof or netstat to confirm the listening port.
Recently I've install Ubuntu 12.10 on my dev machine. also I've installed apache 2.2 &
Php 5.3.8 and Php 5.2.17 and MySQL. Everything works fine and I can browses my sites and projects via 127.0.0.1 & Localhost keyword and Hostname But I cannot access my sites or Apache web server via Local ip address (192.168.1.5).
I run this model on Laptop with Ubuntu 11.10 and can access via 192.168.1.x.
Do you have any idea about this issue please let me to know your XP in this case ?
thanks a million about your patient...
Farzam.
Perhaps your Apache is bounded to localhost only. Look in your Apache configuration file
(httpd.conf) for
Listen 127.0.0.1:80
and replace it with:
Listen 80
or
Listen *:80
Also check the Firewall settings, look for a the line below in the same file:
Allow from 127.0.0.1
and try changing it to:
Allow from all
You should replace the listen line as shown below:
Listen 0.0.0.0:80
Try:
sudo ufw allow from 192.168.1.5
I add Directory tag:
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
Windows Firewall did not have an exception for port 80.
Somehow IIS worked fine, but would not allow Apache port 80. Even disabling the Windows Firewall Service did not allow it.
Search Windows for "Firewall" and Create a new rule. Choose Port, enter 80, Call it: HTTP or whatever, Save. Restart Apache service.
in my case i work on nestjs and
previously i run my project on app.listen(3001) like this
first i change to this app.listen(3001,'192.168.xx.xx')
now i want to access my project on the another computer using ip on the network (LAN)
so it is now allow us to access any particular port after ip address
means if i access 192.198.xx.xx then i can access the address.
but if i append port like this 192.198.xx.xx:3001 then it not let me allow to access ip address so in this case i resolve my problem by run following cmd
sudo service ufw stop
sudo iptables -nvL
sudo iptables -nvL|less
sudo iptables -F
"Windows Firewall did not have an exception for port 80. Somehow IIS worked fine, but would not allow Apache port 80. Even disabling the Windows Firewall Service did not allow it.
Search Windows for "Firewall" and Create a new rule. Choose Port, enter 80, Call it: HTTP or whatever, Save. Restart Apache service." - This worked for me. After I enabled the ports 8080 on the firewall on Win Server 2012 (I use port 8080).