Subdomain Apache2 - apache

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.

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.

Apache2 reverse proxy issues with OTRS

I have asked this question in OTRS forum but their primary focus is the functionality of OTRS and not really the interaction with an apache proxy.
I have an internal server running OTRS (Perl based support ticket system).
I have a reverse proxy in my DMZ that performs proxy and SSL offload for internal web pages/applications. My proxy server is Ubuntu 18 with Apache2. It mostly works except that for OTRS I get weird page errors. It used to not be bad but since update from OTRS 5 to OTRS6 it is so bad that we cannot we https except to log in.
If I use https it throws a message that "OTRS has detected possible network issues" and says to reload the page or wait till the browser establishes connection on it's own. If I wait just a bit I get a new message that states "the connection has been re-established after a temporary connection loss. Due to this elements on this page could have stopped working correctly" it goes on to say that you need to reload the page. But it just keeps cycling through these message in a flapping error.
I also get additional slash marks (/) each time I move to a new ticket.
Like so: https://myotrs.mydomain.com/otrs////////////index.pl?
The slash mark addition happens on both http and https through the proxy. It only happens on the OTRS site, not on my others handled by the same proxy.
Here is sample of my proxy vhost file.
<VirtualHost *:443>
ServerName help.mydomain.com
ServerAlias help.mydomain.net
ServerAdmin it#mydomain.com
ErrorLog /var/log/apache2/proxiedhosts-ssl_error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel info
CustomLog /var/log/apache2/access-ssl.log combined
ProxyRequests off
ProxyPass / http://helpdesk.mydomain.local/
<Location /otrs>
ProxyPassReverse http://helpdesk.mydomain.local/otrs/
</Location>
<Location /otrs-web>
ProxyPassReverse http://helpdesk.mydomain.local/otrs-web/
</Location>
# Use mod_proxy_html to rewrite URLs
SetOutputFilter proxy-html
# commented out
https://help.mydomain.com/otrs/
https://help.mydomain.com/otrs-web/
# Disable compressed communication between Apache and target server
RequestHeader unset Accept-Encoding
# SSL Engine Switch:
# Enable/Disable SSL for this virtual host.
SSLEngine on
# Allows the proxying of an SSL connection
SSLProxyEngine On
# certificate
SSLCertificateFile /etc/ssl/certs/help.mydomain.com/help.mydomain.com.crt
SSLCertificateKeyFile /etc/ssl/private/SHA2_mydomain.key
</VirtualHost>
I have checked out your config file, and i suggest you try to change
<Location /otrs>
ProxyPassReverse http://helpdesk.mydomain.local/otrs/
</Location>
to
<Location /otrs/>
ProxyPassReverse http://helpdesk.mydomain.local/otrs/
</Location>
In the original config file, if you browse https://myotrs.mydomain.com/otrs/index.pl you will be redirect to https://myotrs.mydomain.com/otrs//index.pl. And then, if you click the page, you will be redirect to https://myotrs.mydomain.com/otrs///index.pl. Then you are stuck in the circulation.

Write DNS instead of IP?

I'm working on a project and I would like to make some things in order to be able to handle easier my distant server.
I have a server on which one I installed an API (dolibarr - ERP/CRM software).
This server uses Ubuntu 14.04 and Apache2.
When I want to connect to my software from the net, I open Firefox for example, I write http://172.30.10.XX and I am going to the application login page.
But I would like to create a DNS and domain name in order to connect it easier.
For example :
http://shopmoriba.datasystems.fr instead to write the IP address.
My question is : How I can do that ?
I know that I need to modify some files : /etc/apache2/sites-available/000-default.conf or /etc/hosts but what I need to write exactly ?
My /etc/hosts file looks like :
127.0.0.1 localhost
//127.0.1.1 dolibarr
172.30.10.69 shopmoriba.datasystems.fr
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
My /etc/apache2/sites-available/000-default.conf looks like :
<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
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
Thank you by advance
There should be no need to touch the /etc/hosts on your server.
The important thing to make this work is to make the name known to all clients that want to access your application. To do this you basically have two possibiliies:
Add an entry to all /etc/hosts (on windows this is C:\Windows\System32\drivers\etc/hosts) on all clients that are meant to access your application. Doing it this way is not recommended
Add a DNS-record for shopmoriba.datasystems.fr in some DNS-server that will be accessed by all clients that are meant to access the application. If this is solely for internal use go with some DNS-server on your network, perhaps there already is one. If you want to make the application publicly available there is no way around registering an official domain and publishing the hostname via the associated DNS-server.
While you only run one application on your server this will be sufficient. Once you start adding other application that you want to publish under a different hostname you will have to add more <VirtualHost>-sections and add a ServerName-line like
`ServerName shopmoriba.datasystems.fr`
to the respective VirtualHost-configuration.
I ommited the topic of using https since you did not mention you want to use it and especially on servers hosting multiple vhosts it is enough for a separate topic.
You can add the entry to /etc/hosts in the following format:
172.30.10.XX shopmoriba.datasystems.fr
Bear in mind that this will only work on the local machine where the hosts file has changed.

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.

Apache accepts all websites that point to server

I only have two websites pointed to my server IP, Asite.com and Bsite.com. I tried adding a website, so I pointed Csite.com to my server IP (but I haven't registered a virtualhost for site3.com yet). How come when I access Csite.com apache recognizes it as Asite.com even if I haven't registered a virtualhost for Csite.com?
httpd.conf
Listen 8080
NameVirtualHost *:8080
Asite.com
<VirtualHost *:8080>
ServerAdmin webmaster#localhost
ServerName asite.com
ServerAlias asite.com *.asite.com
DocumentRoot /var/www/asite.com/public
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/asite.com/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/httpd/error_log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
</VirtualHost>
^The same goes for Bsite.com
The first virtualhost is also the default:
"The asterisks match all addresses, so the main server serves no requests. Due to the fact that www.example1.com is first in the configuration file, it has the highest priority and can be seen as the default or primary server. That means that if a request is received that does not match one of the specified ServerName directives, it will be served by this first VirtualHost."
See 'Running several name-based web sites on a single IP address.' http://httpd.apache.org/docs/2.0/vhosts/examples.html
It uses the first-listed one, when it has no ServerName match.
You'll find you can also use the raw IP address to access Asite.com.
If you feel uncomfortable with that, you could create a different virtual host as the first one listed for <VirtualHost *:8080>, and configure so it just Redirects somewhere else. Or gives a 404 message, etc.
This is happening because you pointed the csite.com to your local host and the first virtual host is recognized as local host so if you switch around siteA and siteB so it would be virtual host for sure b first and type in your browser "localhost" or sitec.com it will show siteb.com
Don't worry; this isn't a problem. It is supposed to happen.
You didn't actually point sitec.com to localhost but I if you created it in your hosts file our pointed it to your domain it will take you to the first specified file!