I have a VPS server with SSL Certbot, in Debian with apache, but not working correctly for subdomains. When accessing my subdomain with http://, it goes directly to the directory that I configure.
But, when accessing with https:// protocol, it goes directly to the root directory, that is /var/www/html.
I am new to the VPS servers, and I not know what's the problem.
This is my /etc/apache2/sites-available/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.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
RewriteEngine on
RewriteCond %{SERVER_NAME} =app.mysite.com [OR]
RewriteCond %{SERVER_NAME} =mysite.com [OR]
RewriteCond %{SERVER_NAME} =www.mysite.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
<VirtualHost *:80>
ServerName app.mysite.com
DocumentRoot /var/www/html/app
</VirtualHost>
Thanks for your time
Your configuration sample is missing the configuration for https / port 443.
From your http configuration
<VirtualHost *:80>
ServerName app.mysite.com
DocumentRoot /var/www/html/app
</VirtualHost>
So you should change the DocumentRoot of your SSL-configuration file also to DocumentRoot /var/www/html/app. Probably this file is called 000-default-ssl.conf.
Usually it is a good idea to create is own files and use them instead of the default ones. Especially when you do a dist upgrade and configuration files change this is much less hassle, because when changing default files you get a dialog and have to decide which version you want to keep. Selecting the wrong and you have to restore your changed config-file from a backup.
Related
I have a subdomain test.example.com.
I have a java web application running in tomcat 8.5 on port 8086.
In /opt/tomcat/conf/server.xml I have a virtual host defined like below.
<Host name="canicarry.thehatapps.com" appBase="webapps/SecondAmendmentSupporters-0.2" unpackWARs="true" autoDeploy="true">
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="canicarry_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
I have an apache2 conf defines like below.
/etc/apache2/sites-available/test.example.com.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
ServerName test.example.com
ServerAlias www.test.example.com.com
DocumentRoot /var/www/test.example.com/public_html
<Directory /var/www/test.example.com/public_html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
# 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>
In public_html I have .htaccess defined like below.
RedirectPermanent / http://test.example.com:8086
My goal is to be able to hit the myapp-02 tomcat web app on port 8086 like so http://canicarry.thehatapps.com:8086
I'm not sure what's wrong but I get 404. I can't seem to resolve http://canicarry.thehatapps.com:8086 to my web app running in tomcat.
Any help would be appreciated.
EDITED-----------
Using this in my apache conf file helped but still running into issues.
<VirtualHost canicarry.thehatapps.com/*:80>
ServerName canicarry.thehatapps.com
ProxyRequests Off
ProxyPass / ajp://localhost:8086/SecondAmendmentSupporters-0.2
ProxyPassReverse / ajp://localhost:8086/SecondAmendmentSupporters-0.2
</VirtualHost>
When I type http://canicarry.thehatapps.com:8086, I'm taken to
http://104.238.96.249:8086/SecondAmendmentSupporters-0.2/
Which is the full url to my tomcat application. However, when I append an endpoint, it doesn't resolve. In addition, the url should still be http://canicarry.thehatapps.com:8086. It shouldn't show the full url to the tomcat application instance.
For example, http://canicarry.thehatapps.com:8086/places should return a list of places from the service but it doesn't resolve the url.
Your <VirtualHost *:80> is telling apache to listen on port 80.
If you want the application to be exposed over port 8086 then you need to proxy the port 8086 to your tomcat server. You can do this using the ajp_proxy module of apache.
<VirtualHost test.example.com:8086>
ServerName test.example.com
ProxyRequests Off
ProxyPass /examples ajp://127.0.0.1:8086/examples
ProxyPassReverse /examples ajp://localhost:8086/examples
</VirtualHost>
See below article for details
https://linuxconfig.org/how-to-set-up-apache-webserver-proxy-in-front-of-apache-tomcat-on-red-hat-linux
I have an Ubuntu 16.04 server running nagios3 from the apt repo.
I get the message The requested URL/< was not found on this server
The config file in etc/apache2/sites-available which is soft linked to sites-enabledconfig;
<VirtualHost *:443>
# 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 monitor.server.com
SSLEngine on
SSLCertificateFile /etc/ssl/certs/server.com.bundle.pem
SSLCertificateKeyFile /etc/ssl/private/server.com.key
SSLCACertificateFile /etc/ssl/certs/ca-certificates.crt
ServerName monitor.novarumcloud.com
DocumentRoot /usr/share/nagios3/htdocs
ScriptAlias /cgi-bin/nagios3 /usr/lib/cgi-bin/nagios3
ScriptAlias /nagios3/cgi-bin /usr/lib/cgi-bin/nagios3
Alias /nagios3/images /usr/share/nagios3/htdocs/images
Alias /images /usr/share/nagios3/htdocs/images
Alias /nagios3/stylesheets /etc/nagios3/stylesheets
Alias /stylesheets /etc/nagios3/stylesheets
Alias /nagios3/js /usr/share/nagios3/htdocs/js
<DirectoryMatch (/usr/share/nagios3/htdocs|/usr/lib/cgi-bin/nagios3|/etc/nagios3/stylesheets)>
Options FollowSymLinks
DirectoryIndex index.php index.html
AllowOverride AuthConfig
Order Allow,Deny
Allow From All
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /etc/nagios3/htpasswd.users
require valid-user
</DirectoryMatch>
<Directory /usr/lib/cgi-bin/nagios3>
Options +ExecCGI
</Directory>
Why is this happening? I'm sure it's probably a simple config error on my part. I have SSL certificates installed and only port 443 open too
Okay ive been attempting this for days without any results and i really hope that some of you can help me.
I have problems with google not indexing my website meaning it cannot see the content of my website.
My website is an angular application.
So i saw this post ng-newletter saying that i could use apache so my configs are as follow:
$ a2enmod proxy
$ a2enmod proxy_http
Which enables proxy
Then i have edited my virtualhost with the following:
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port t$
# 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.
ServerAdmin webmaster#localhost
ServerName www.mydomain.dk
ServerAlias mydomain.dk
DocumentRoot /var/www/mydomain/
RewriteEngine On
Options +FollowSymLinks
RewriteCond %{REQUEST_URI} ^/$
RewriteCond %{QUERY_STRING} ^_escaped_fragment_=/?(.*)$
RewriteRule ^(.*)$ /snapshots/%1? [NC,L]
# 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".
# 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
<Directory /var/www/mydomain/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Now when i attempt to run the google-bot-simulator i get some odd response:
No matter which url i go to it tells me that it has redirected back to index
and i am now unable to go to www.mydomain/subsite without getting a 404
So what am i doing wrong?
Answer from google
HTTP/1.1 301 Moved Permanently
Date: Thu, 17 Sep 2015 13:13:27 GMT
Server: Apache/2.4.7 (Ubuntu)
Location: http://mydomain.dk/products
Content-Length: 315
Keep-Alive: timeout=5, max=99
Connection: Keep-Alive
Content-Type: text/html; charset=iso-8859-1
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved here.</p>
<hr>
<address>Apache/2.4.7 (Ubuntu) Server at www.mydomain.dk Port 80</address>
</body></html>
I'm trying to run a website on both port 80 and 1998 on apache2 and in sites-available my config looks like this:
<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 admin#mafiakampen.com
DocumentRoot /var/www/html/mv
# 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
<VirtualHost *:1998>
# 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 admin#mafiakampen.com
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>
Then I restarted apache2 and rsent the command iptables -A INPUT -p tcp --dport 1998 --jump ACCEPT.
Now when I'm going to myserverip:1998 I get that the page isn't available and under that ERR_CONNECTION_REFUSED. How can I fix this?
I forgot to go to /etc/apache2/ports.conf and add Listen 1998
then i added NameVirtualHost *:1998 in my virtualhost
This days I sleep with my http://localhost working, and reading pages from /var/www...
I woke up with an "AH00094" error at Apache2 log, and (Apache2 created?) a surprised /var/www/html, that Apache2 try to use.
Now my http://localhost/anything not works (error 404 at browser).
How to fix it? I need back my http://localhost working with files at /var/www!
Context
I am using Ubuntu12 with Apache2, all default and standard.
I checked out error log by tail /var/log/apache2/error.log in order to find out exact path that Apache, that shows
... [core:notice] [pid 1597] AH00094: Command line: '/usr/sbin/apache2'
... [:error] [pid 1604] [client 127.0.0.1:40624] script '/var/www/html/info.php' not found or unable to stat
The folder /var/www/html is new, all, like '/var/www/info.php', are at /var/www, not at /var/www/html.
I fixed the "AH00094" error editing
sudo nano /etc/apache2/apache2.conf
and adding at last line
ServerName localhost
(now no log errors about localhost, but nothing works)
PS: I checked other related issues, but not is the same problem: Permissions for /var/www/html , Attempting to use symbolic link for var/www/html
I'm afraid to use the clues of this answer ... in my Ubuntu there are no the .conf indicated files. I must create it? Is secure?
As #RahilWazir suggested, here is also my "/etc/apache2/sites-available/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.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
See here:
Why has the apache2 www dir been moved to /var/www/html?
The default directory apparently (we were also surprised) moved from /var/www to /var/www/html for htdocs in Debian, and Ubuntu copied this change. The reasons given are somewhat sound, but the upgrade path is probably “interesting” (as in the Chinese proverb)… as you have encountered.
If you want to use /www as root folder instead of /www/html you can simply edit the apache2 config file to have /var/www
Edit 000-default.conf
sudo gedit /etc/apache2/sites-available/000-default.conf
then change
DocumentRoot /var/www/html
to
DocumentRoot /var/www
Restart apache2 server :
sudo service apache2 restart