Ubuntu server (apache) won't respond to external requests - apache

I'm fairly new to this so I could be missing something totally obvious, but I can't connect to my server using my external IP. Internally everything works like a dream (10.0.0.28/redmine), but when I try to connect using the external IP the requests time out. I forwarded both my ssh port and port 80 as shown below, but that didn't solve the problem.
My ports now show as being open with www.portchecktool.com.
SSH works fine internally, but when I issue the command shown here it says connection closed by remote host.
ssh {my external ip} -pxxxx -i /home/millerir/.ssh/id_rsa -l imiller
Similarly when I navigate to {my ip}/redmine or {my ip} or {my_ip}:80 or my ddns service address I get connection reset while trying to connect errors from my browser.
I did check that the server was listening on port 80 and my ssh port as shown below.
me#ubuntu-server:/etc/apache2/sites-available$ sudo netstat -tulpn | grep LISTEN
tcp 0 0 0.0.0.0:xxxx 0.0.0.0:* LISTEN 779/sshd
tcp 0 0 127.0.0.1:57384 0.0.0.0:* LISTEN 1192/redmine
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 862/mysqld
tcp6 0 0 :::xxxx :::* LISTEN 779/sshd
tcp6 0 0 :::80 :::* LISTEN 923/apache2
If anyone could help me that would be greatly appreciated. I'm stuck and kind of clueless.
redmine.conf
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster#localhost
#DocumentRoot /var/www/html
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
DocumentRoot /var/www
<Directory /var/www/redmine>
RailsBaseURI /redmine
PassengerResolveSymLinksInDocumentRoot on
</Directory>
</VirtualHost>
http.conf
<Listen 80
<IfModule ssl_module>
Listen 443
</IfModule>
<IfModule mod_gnutls.c>
Listen 443
</IfModule>

So I figured out after digging around that some routers don't like you going "out and back in". I tried connecting to my server using data on my phone and it works now.

Related

Virtualhost on macos mamp ERR_CONNECTION_REFUSED

I have a Mac under MacOS Big Sur (when I had Catalina, the problem was also present) with MAMP
I would like to create a virtual host
Here is what I did:
in Application/MAMP/conf/apache/httpd.conf, I uncommented the line
Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
in /private/etc/hosts I added
127.0.0.1 test.deva
127.0.0.1 test.localhost
here is my Application/MAMP/conf/apache/httpd-vhosts.conf file
#
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.2/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.
#
# Use name-based virtual hosting.
#
NameVirtualHost *
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
<VirtualHost *:8888>
DocumentRoot /Aplications/MAMP/htdocs
ServerName localhost
</VirtualHost>
<VirtualHost *:8888>
DocumentRoot "/Applications/MAMP/htdocs/testhost"
ServerName test.deva
ServerAlias www.test.deva
</VirtualHost>
In the parameters of MAMP I checked, I have the port 8888
In htdocs/testhost I just have an index.html file
i tried a lot of things i saw here on posts where the problem was the same
But I still have an ERR_CONNECTION_REFUSED error
How to do it please?
I faced the same issue on macOS Big Sur with a Docker setup for local web development.
It turned out the problem was that port 80.
Changing the configuration to listen on port 8080 solved the issue for me.

VirtualHosts Not Working for Locally Hosted Apache Web Server

I have an apache web server setup on my development machine (macos sierra). The configuration I had setup has been working fine for months, but for some reason it decided to stop working today. I have to include the port number (i.e. mysite.local.com:8080) for any locally hosted site I want to navigate to. If I leave off the port number I get ERR_EMPTY_RESPONSE in the browser. The config test is passing with no errors. I haven't upgraded or changed anything on this machine (that I can recall) that would cause virtual hosts to stop working. Can anyone suggest a way to pin down what the issue is here?
FYI
sudo apachectl -S produces
VirtualHost configuration:
*:87 bto.local.tura.com (/private/etc/apache2/sites-enabled/bto.local.tura.com.conf:2)
*:8080 is a NameVirtualHost
default server mr.local.tura.com (/private/etc/apache2/sites-enabled/mr.local.tura.com.conf:1)
port 8080 namevhost mr.local.tura.com (/private/etc/apache2/sites-enabled/mr.local.tura.com.conf:1)
port 8080 namevhost optics.local.tura.com (/private/etc/apache2/sites-enabled/optics.local.tura.com.conf:1)
*:85 overstock.local.tura.com (/private/etc/apache2/sites-enabled/overstock.local.tura.com.conf:1)
*:86 static.local.tura.com (/private/etc/apache2/sites-enabled/static.local.tura.com.conf:1)
My httpd.conf:
Listen 8080
Listen 85
Listen 86
Listen 87
...
ErrorLog "/var/log/apache2/error.log"
...
Include /private/etc/apache2/sites-enabled/*.conf
An example of a vhhost config file:
<VirtualHost *:85>
ServerName overstock.local.tura.com
DocumentRoot /usr/local/web/overstock
ErrorLog /var/log/apache2/overstock.local.tura.com.error.log
CustomLog /var/log/apache2/overstock.local.tura.com.access.log "combined"
<Directory "/usr/local/web/overstock">
Order Deny,Allow
Deny from all
Allow from all
Options -Indexes +FollowSymLinks
</Directory>
LogLevel emerg
</VirtualHost>
I think you should add
Listen 80
try by changing deny from none in place of deny from all
what are errors from /var/log/apache2/error.log ,paste the content of error.log

Subdomain Apache2

its the first time I try to host a website.. First i bought an domain on "Strato" and I got apache running on this domain via a ubuntu server and our fitzbox using Dyndns. But now i want to do the next step and host a subdomain. I created a subdomain on the strato web interface and tryed to set it up in apache, but i can't connect to it. If i change the DynDns in our fritzbox to the subdomain i can connect to the subdomain but not to the normal Domain, u know what i can do to reach both of them via the internet?
In apache I created this 2 files: 000.default.conf ---- both of them are enabled
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
ServerName www.SaneQt.de
ServerAdmin webmaster#localhost
DocumentRoot /var/www/000
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
001-oneway.conf
<VirtualHost *:80>
ServerName onewaygaming.saneqt.de
DocumentRoot /var/www/001
</VirtualHost>
FritzboxSettings: port 80 is open and I used this setting Fritzbox DynDns Settings
Strato: Strato Domains
Im really sry for my english, im not the best in scool i hope u can ignore the fact...
Thanks in advance!!
Your apache settings are OK, the problem is with DNS:
onewaygaming.saneqt.de:
;QUESTION
onewaygaming.saneqt.de. IN A
;ANSWER
onewaygaming.saneqt.de. 149 IN A 81.169.145.156
www.SaneQt.de:
www.SaneQt.de. IN A
;ANSWER
www.SaneQt.de. 149 IN CNAME SaneQt.de.
SaneQt.de. 59 IN A 46.243.84.57
At this moment, http://www.saneqt.de/ is responding with Hallo welt so I guess that it has correct settings. If so, you need to configure the CNAME record for onewaygaming.saneqt.de exactly the same as you did for www.SaneQt.de.

Website resolves to local address using apache reverse proxy

I have set up a reverse proxy with apache and am pointing to 4 other apache wordpress server vm's on my local network.
When I go to the websites on 3 of them (like www.mywebsite.com externally from my computer at work), they resolve fine and the sites produce the page correctly.
When I try to connect to the 4th site, it redirects me to a 192 address which is what I have in the proxy config but it does not resolve correctly like the other sites. I literally copy and pasted each block in the 000-default.conf so I know they are identical.
The proxy works and is moving the traffic but will try to resolve locally. Here is the block from my 000-default.conf.
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
ServerName www.mywebsite.com
ServerAdmin myemail#gmail.com
DocumentRoot /var/www/html
ProxyPass / http://192.168.1.23:80/
ProxyPassReverse / http://192.168.1.23:80/
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
Im not sure what is different between the sites. Ive done this quite a few times and never had the issue. Could this be an issue with the web server on the 4th site? These are all VM's running ubuntu server with lamp.
It looks like it was an issue with the 4th server and how it was handling the index file with wordpress. It seems that Wordpress had to be provisioned locally first. But, I dont remember doing this with the other sites. All is well now.

How to solve issue – Port 8040 the connection has timed out..why?

I want to configure apache to listen on port 8040
I added LISTEN 8040 directive in httpd.conf
Listen 8040
ServerName localhost:8040
and assign this port number to my project in httpd-vhosts.conf
<VirtualHost *:8040>
ServerAdmin "webmaster#dummy-host2.example.com"
DocumentRoot "/opt/lampp/htdocs/project"
ServerName "localhost:8040"
ErrorLog "logs/error.log"
CustomLog "logs/access.log" common
</VirtualHost>
and restarted the server.
but it shows this error
The connection has timed out.The site could be temporarily unavailable or too busy.
same process done for port number 80
Listen 80
ServerName localhost:80
it's working fine.
other port numbers not taking why?
what else do I need to configure???? Please help.
If it matters, I use centOS server.
any help is great appreciation.
You should probably allow port 8040 in your firewall.