Unable to access Apache2 HTTPD server on browser from remote machine - apache2

I have a website deployed on Apache2. The Apache2 server is setup on a VM.
When I try to access the site using a browser from a remote machine (my laptop), I get a connection timed out error.
When I try to access something deployed on Tomcat on the same VM it works fine. But Apache gives a problem.
Please let me know what I am missing.
Thanks.

1) check that the httpd process is running
ps -ef | grep httpd |grep -v grep
2) make sure you are broadcasting on port 80
netstat -atn |grep :80
3) verify in your conf (/etc/httpd/conf.d/*.conf) file that you are binding Apache to port 80
<virtualhost *:80>
or
<virtualhost xxx.xxx.xxx.xxx:80>
Your Tomcat process may be bound to port 80 and the socket is not available.

on centos run this commands:
iptables -I INPUT 4 -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
/etc/init.d/iptables save

Related

How to change the default port of Graphite web-app?

I tried searching in the /opt/graphite/webapp/graphite/local_settings.py file. But I did not find how to change the default port 80.
Actually, I wanted to install OMD on the same machine which by default installs on 80 port.
Link for graphite doc
I recommend using docker image for this purpose, you can download here: https://hub.docker.com/r/graphiteapp/docker-graphite-statsd
Getting the Docker image:
docker pull graphiteapp/docker-graphite-statsd
start the docker, you can change the port easily:
docker run -d --name graphite --restart=always -p 80:80 -p 2003-2004:2003-2004 -p 2023-2024:2023-2024 -p 8125:8125/udp -p 8126:8126 graphiteapp/docker-graphite-statsd
vim /etc/apache2/ports.conf and then add below line and save
Listen 192.168.1.1:4000
vim /etc/apache2/sites-available/apache2-graphite.conf
and change the port 80 into desire port
systemctl reload apache2
The recommended way to serve webapp is to use as WSGI backend
From http://graphite.readthedocs.io/en/latest/install.html#dependencies
A WSGI server and web server. Popular choices are:
Apache with mod_wsgi
gunicorn with nginx
uWSGI with nginx
So to change port configure accordingly a vhost in the server (nginx or apache or other) of you choice to listen on the desired port.
If you want to serve via Django's runserver simply specify the port
/manage.py runserver 0.0.0.0:<your_port>

sailsjs refuses connection on address localhost

I am developing an app consisting sailsjs in backend and ng-boilerplate in frontend. In my dev machine(64 bit ubuntu) is all working. But when I put my app for testing purposes into a 32bit debian machine, sailsjs is refusing connection on address
http://localhost:1337/blog.
When I replace localhost with hostname of my debian-machine, like that:
http://debian:1337/blog, all is going to work.
This is error message in browser console:
GET http://localhost:1337/blog net::ERR_CONNECTION_REFUSED
This is content my /etc/hosts file:
127.0.0.1 localhost
#127.0.0.1 debian
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters</pre>
This is content of my /etc/hostname:
debian
Could someone solve this mystery?
So, I add some things:
/config/env/development.js:
module.exports = {
models: {
connection: 'PeeterMongodbServer',
migrate: 'alter'
}
};
My /config/http.js is just empty, it means as it was when I have sails installed.
Try ifconfig or ipconfig as applicable
FOR e.g inet 192.168.1.64
Also update your etc/hosts file
$ cat /etc/hosts
127.0.0.1 localhost
192.168.1.64 debian
Pls ensure this is tabbed between IP address and hostname.

Apache 2.4 virtual host on different port than 80

When reading the articles it all seems easy, but I am unable to get this to work. I run apache 2.4.7
Several virtual hosts are running just fine. I need one virtual host to run at port 8080 only. So I added Listen 8080 to ports.conf
In the virtualhost conf file:
VirtualHost *:8080>
After a restart I am not getting the virtual host. I do see the default server page and I also notice that the Listen 8080 line is working.
What am I forgetting?

How to make Apache2/Httpd trust all client certs

I have an apache2/httpd install on centos fronting a tomcat instance and I want it to trust all client certificates.
How should I go about it?
There is no such thing as 'SSL Passthrough' with Apache since Apache needs to handle the SSL negotiation. Things I may think of are
Do not use Apache but perform TCP forwarding, using a NAT rule for instance (/sbin/iptables -I PREROUTING -t nat -p tcp -d test.server.ip --dport 443 -j DNAT --to :8443). If you have two IP addresses assigned to the machine, your NAT rule can redirect based on the destination IP.
You could configure a virtual host in Apache dedicated to test where you set SSLVerifyClientto none. This Virtual Host has a reverse proxy rule mapping directly to the non SSL http port of your Tomcat instance, or maps to the HTTP/S port and then you set the SSLProxyMachineCertificateFile with certs that Apache can present to authenticate to Tomcat

Configure apache to listen on port other than 80

I use centOS server. I want to configure apache to listen on port 8079.
I added LISTEN 8079 directive in httpd.conf.
I opened port 8079 in iptables and restarted iptables. I even stopped iptables service.
"netstat -nal | grep 8079" shows "tcp 0 0 :::8079 :::* LISTEN"
If I try to access http://localhost:8079 or http://myserver.com:8079 from that machine, I can access that page. BUT from any other machine I am not able to access the site on any port other than 80. On port 80, it works. On port 8079 it does not.
What else do I need to configure?
In /etc/apache2/ports.conf, change the port as
Listen 8079
Then go to /etc/apache2/sites-enabled/000-default.conf
And change the first line as
<VirtualHost *: 8079>
Now restart
sudo service apache2 restart
Apache will now listen on port 8079 and redirect to /var/www/html
Open httpd.conf file in your text editor.
Find this line:
Listen 80
and change it
Listen 8079
After change, save it and restart apache.
It was a firewall issue. There was a hardware firewall that was blocking access to almost all ports. (Turning off software firewall / SELinux bla bla had no effect)
Then I scanned the open ports and used the port that was open.
If you are facing the same problem, Run the following command
sudo nmap -T Aggressive -A -v 127.0.0.1 -p 1-65000
It will scan for all the open ports on your system. Any port that is open can be accessed from outside.
Ref.: http://www.go2linux.org/which_service_or_program_is_listening_on_port
If you need apache Listen port other than 80, you should add next file under ubuntu
"/etc/apache2/ports.conf"
the list of Listen ports
Listen 80
Listen 81
Listen 82
After you have to go on your Virtual hosts conf file and define next
<VirtualHost *:80>
#...v host 1
</VirtualHost>
<VirtualHost *:81>
#...host 2
</VirtualHost>
<VirtualHost *:82>
#...host 3
</VirtualHost>
This is working for me on Centos
First: in file /etc/httpd/conf/httpd.conf
add
Listen 8079
after
Listen 80
This till your server to listen to the port 8079
Second: go to your virtual host for ex. /etc/httpd/conf.d/vhost.conf
and add this code below
<VirtualHost *:8079>
DocumentRoot /var/www/html/api_folder
ServerName example.com
ServerAlias www.example.com
ServerAdmin root#example.com
ErrorLog logs/www.example.com-error_log
CustomLog logs/www.example.com-access_log common
</VirtualHost>
This mean when you go to your www.example.com:8079 redirect to
/var/www/html/api_folder
But you need first to restart the service
sudo service httpd restart
If you are using Apache on Windows:
Check the name of the Apache service with Win+R+services.msc+Enter (if it's not ApacheX.Y, it should have the name of the software you are using with apache, e.g.: "wampapache64");
Start a command prompt as Administrator (using Win+R+cmd+Enter is not enough);
Change to Apache's directory, e.g.: cd c:\wamp\bin\apache\apache2.4.9\bin;
Check if the config file is OK with: httpd.exe -n "YourServiceName" -t (replace the service name by the one you found on step 1);
Make sure that the service is stopped: httpd.exe -k stop -n "YourServiceName"
Start it with: httpd.exe -k start -n "YourServiceName"
If it starts alright, the problem is no longer there, but if you get:
AH00072: make_sock: could not bind to address IP:PORT_NUMBER
AH00451: no listening sockets available, shutting down
If the port number is not the one you wanted to use, then open the Apache config file (e.g. C:\wamp\bin\apache\apache2.4.9\conf\httpd.conf open with a code editor or wordpad, but not notepad - it does not read new lines properly) and replace the number on the line that starts with Listen with the number of the port you want, save it and repeat step 6. If it is the one you wanted to use, then continue:
Check the PID of the process that is using that port with Win+R+resmon+Enter, click on Network tab and then on Ports subtab;
Kill it with: taskkill /pid NUMBER /f (/f forces it);
Recheck resmon to confirm that the port is free now and repeat step 6.
This ensures that Apache's service was started properly, the configuration on virtual hosts config file as sarul mentioned (e.g.: C:\wamp\bin\apache\apache2.4.9\conf\extra\httpd-vhosts.conf) is necessary if you are setting your files path in there and changing the port as well. If you change it again, remember to restart the service: httpd.exe -k restart -n "YourServiceName".
For FC22 server
cd /etc/httpd/conf
edit httpd.conf [enter]
Change:
Listen 80
to:
Listen whatevernumber
Save the file
systemctl restart httpd.service [enter]
if required, open whatevernumber in your router / firewall
Run this command if your ufw(Uncomplicatd Firewall) is enabled .
Add for Example port 8080
$ sudo ufw allow 8080/tcp
And you can check the status by running
$ sudo ufw status
For more info check :
https://linuxhint.com/ubuntu_allow_port_firewall

Resources