Reverse Proxy not running on HTTPS Apache Server - apache

Created a Hello_World NodeJS App.
The app is accessible at http://<DOMAIN_NAME>/app & http://<DOMAIN_NAME>:3000
but when accessed via https://<DOMAIN_NAME>/app it returns an error.
http://<SERVER_IP>:3000 also works & https:<SERVER_IP>:3000 returns an error
sudo apachectl -S
OUTPUT :
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
VirtualHost configuration:
*:80 okoyama.in (/etc/apache2/sites-enabled/okoyama.in.conf:1)
*:443 okoyama.in (/etc/apache2/sites-enabled/okoyama.in.conf:45)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex default: dir="/var/run/apache2/" mechanism=default
Mutex mpm-accept: using_defaults
Mutex watchdog-callback: using_defaults
Mutex proxy-balancer-shm: using_defaults
Mutex rewrite-map: using_defaults
Mutex ssl-stapling-refresh: using_defaults
Mutex ssl-stapling: using_defaults
Mutex proxy: using_defaults
Mutex ssl-cache: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33
Group: name="www-data" id=33
<VirtualHost *:80>
ServerAdmin admin#okoyama.in
ServerName okoyama.in
ServerAlias www.okoyama.in
DocumentRoot /var/www/okoyama.in/public_html
ProxyPreserveHost On
ProxyPass /app http://localhost:3000/
ProxyPassReverse /app http://localhost:3000/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<IfModule mod_ssl.c>
<VirtualHost *:443>
DocumentRoot /var/www/okoyama.in/public_html
ServerName okoyama.in
SSLEngine on
SSLCertificateFile /etc/ssl_install/certificate.crt
SSLCertificateKeyFile /etc/ssl_install/private.key
SSLCertificateChainFile /etc/ssl_install/ca_bundle.crt
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
</IfModule>
The above code has Reverse Proxy enabled for HTTP. HTTPS works normally. I have removed the Reverse Proxy section from 443 Port for now to make the working code cleaner.
Multiple variations of solutions suggested on various platforms have been tried in Port 443 section but none worked until now.
The included turning on SSLProxyEngine & a similar Proxy method as mentioned in the HTTP section.
Suggest possible solution. I will retry & post for clarity.

Related

Why is reverse proxy with Apache returning different results?

Same url with remote server and local server return different things.
This is the local server bringing the content from remote server
This is the remote server original content
Listen 443
SSLProtocol all -SSLv2 -SSLv3
SSLHonorCipherOrder on
SSLCipherSuite ----hidden----
SSLPassPhraseDialog builtin
SSLSessionCache "shmcb:----hidden----(512000)"
SSLSessionCacheTimeout 300
SSLEngine on
SSLProxyEngine on
SSLProxyVerify none
SSLProxyCheckPeerCN off
SSLProxyCheckPeerName off
ProxyPass /_next https://profiles-three.vercel.app/_next
ProxyPassReverse /_next https://profiles-three.vercel.app/_next
This is my apachectl -S print
VirtualHost configuration:
*:80 localhost (/opt/bitnami/apache2/conf/bitnami/bitnami.conf:8)
*:443 localhost (/opt/bitnami/apache2/conf/bitnami/bitnami.conf:46)
ServerRoot: "/opt/bitnami/apache2"
Main DocumentRoot: "/opt/bitnami/apache2/htdocs"
Main ErrorLog: "/opt/bitnami/apache2/logs/error_log"
Mutex proxy-balancer-shm: using_defaults
Mutex ssl-stapling-refresh: using_defaults
Mutex rewrite-map: using_defaults
Mutex ssl-stapling: using_defaults
Mutex proxy: using_defaults
Mutex ssl-cache: using_defaults
Mutex default: dir="/opt/bitnami/apache2/logs/" mechanism=default
PidFile: "/opt/bitnami/apache2/logs/httpd.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
Define: USE_PHP_FPM
User: name="daemon" id=1
Group: name="daemon" id=1

virtual host setup shows default apache2 page

I have setup a new virtual host on my ubuntu 16.04 machine but it redirects me to apache's default virtual host (which is disabled).
Below is the contents of the apache virtual hosts config file;
VirtualHost configuration:
*:80 roomba.dev (/etc/apache2/sites-enabled/roomba.dev.conf:2)
*:443 is a NameVirtualHost
default server roomba.dev (/etc/apache2/sites-enabled/default-ssl.conf:2)
port 443 namevhost roomba.dev (/etc/apache2/sites-enabled/default-ssl.conf:2)
port 443 namevhost roomba.dev (/etc/apache2/sites-enabled/roomba.dev.conf:10)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex watchdog-callback: using_defaults
Mutex rewrite-map: using_defaults
Mutex ssl-stapling-refresh: using_defaults
Mutex ssl-stapling: using_defaults
Mutex proxy: using_defaults
Mutex ssl-cache: using_defaults
Mutex default: dir="/var/lock/apache2" mechanism=fcntl
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33
Group: name="www-data" id=33
the domain is https://roomba.dev
You do not really have a question but based on the fact that I too am trying to setup a virtual host if not several, I have found a work around for the official Ubuntu virthost setup tutorial and the associated docs . They just do not work, see these comments and the confusion that ensued. I am assuming the were providing a clean way to add virtualhosts, similar to how you add APT lists in Linux.
Define your new virtual host in the default-ssl.conf file:
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
...
</VirtualHost>
</IfModule>
I hope that you did not delete it. After that first virtual host closing tag, add a new host as described in the tutorial instead of creating a new configuration file. For example;
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
...
</VirtualHost>
<VirtualHost *:80>
#ServerAdmin admin#roomba.dev
DocumentRoot /path/to/new/virtualhost
ServerName roomba.dev
ErrorLog ${APACHE_LOG_DIR}/roomba-error.log
CustomLog ${APACHE_LOG_DIR}/roomba-access.log combined
</VirtualHost>
</IfModule>
You can add as many as you want. I am still searching for documentation that could discourage this with explanations. As again, the Apache tutorial does not work but this does, yet they bothered to write it that way, several times. There must be a reason why.
NB: do not touch any permissions. Except the original virtual server directories, based on the http error codes.

VirtualHost with two domains doesn't work

I can't configure two domains with VirtualHost, because, always show me only one domain. I mean, if I visit domainB.com that redirect me to domainA.com and domainA.com works fine. I made this procedure in anothers hosts like: DigitalOcean or my own localhost, but with this instance I can't find the issue. If I disable one site the other works without problem.
I have a google instance with Ubuntu 17.10 and Apache2 with two domains (virtualhost). I disabled the default virtualhost. My folder structure is /var/www/domainA/ and /var/www/domainB/
Cloud DNS is configured with two zones domainA.com and domainB.com with A and CNAME records point to my server IP. I have too NS records pointed to googledomains.com and in my registar I added those DNS.
If I do a ping to both domains, them resolve correctly to my IP address without problem.
I have the two domains configured in sites-available:
#in /etc/apache/sites-available/domainA.com.conf
<VirtualHost *:443>
ServerAdmin webmaster#domainA.com
ServerName domainA.com
ServerAlias www.domainA.com
DocumentRoot /var/www/domainA
ErrorLog ${APACHE_LOG_DIR}/error-domainA.log
CustomLog ${APACHE_LOG_DIR}/access-domainA.log combined
SSLEngine on
SSLCertificateFile /etc/apache2/sslcert/certified-number.crt
SSLCertificateKeyFile /etc/apache2/sslcert/domainA.com.key
SSLCertificateChainFile /etc/apache2/sslcert/gd_bundle-g2-g1.crt
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory /var/www/domainA/>
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars
</Directory>
</VirtualHost>
#in /etc/apache/sites-available/domainB.com.conf
<VirtualHost *:80>
ServerAdmin webmaster#domainB.com
ServerName domainB.com
ServerAlias www.domainB.com
DocumentRoot /var/www/domainB
ErrorLog ${APACHE_LOG_DIR}/error-domainB.log
CustomLog ${APACHE_LOG_DIR}/access-domainB.log combined
<Directory /var/www/domainB/>
Options FollowSymLinks
AllowOverride All
</Directory>
</VirtualHost>
Result of apachectl -S command:
sudo apache2ctl -S
VirtualHost configuration:
*:80 domainB.com (/etc/apache2/sites-enabled/domainB.conf:1)
*:443 domainA.com (/etc/apache2/sites-enabled/domainA.conf:1)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex rewrite-map: using_defaults
Mutex ssl-stapling-refresh: using_defaults
Mutex ssl-stapling: using_defaults
Mutex ssl-cache: using_defaults
Mutex default: dir="/var/run/apache2/" mechanism=default
Mutex mpm-accept: using_defaults
Mutex watchdog-callback: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33
Group: name="www-data" id=33
What other setting I must to check?
UPDATE INFORMATION: If I try with www for the domainA, works fine.
www.domainA.com -> Works
domainA.com -> Doesn't work, redirect to domainB.com
www.domainB.com -> Works
domainB.com -> Works
I had only a VirtualHost configuration in the port 443 for domainA.com.
I added a configuration *:80 with a redirection to ssl and works. Like this:
<VirtualHost *:80>
ServerAdmin webmaster#domainA.com
ServerName domainA.com
ServerAlias www.domainA.com
Redirect / https://www.domainA.com/
</VirtualHost>
Thanks Matt Raines for his comment.

Apache Virtual Host (Ubuntu) redirecting to wrong document root

I'm trying to setup an Apache server with several virtual hosts (www.domain.com & store.domain.com), but for some reason, when I just have one of them enabled (store.domain.com) Apache redirects to the wrong document root (/var/www), which is apparently the default one. This is the virtual host configuration file for the one that's not redirecting correctly:
<VirtualHost *:80>
ServerName store.domain.com
ServerAdmin mail#domain.com
DocumentRoot /var/www/store/public_html/
ErrorLog /var/www/store/logs/error.log
CustomLog /var/www/store/logs/access.log combined
</VirtualHost>
When I run the command apache2ctl -S I get the following:
Name or service not known: AH00547: Could not resolve host name *80 --ignoring!
AH00558: apache2: Could not reliably determine the server's fully qualified domain name,
using xxx.xxx.xxx.xxx. Set the 'ServerName' directive globally to suppress this message
VirtualHost configuration:
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www"
Main ErrorLog: "/var/log/apache2/error.log
Mutex watchdog-callback: using_defaults
Mutex rewrite-map: using_defaults
Mutex ssl-stapling: using_defaults
Mutex ssl-cache: using_defaults
Mutex default: dir="/var/lock/apache2" mechanism=fcntl
Mutex mpm-accept: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
....
Looks like the key is on the first line of the previous error, but I can't figure out what's wrong.
When I have the following virtual host enabled, it works fine:
<VirtualHost *:80>
ServerAdmin mail#domain.com
ServerName www.domain.com
DocumentRoot /var/www/html/www/public_html/
ErrorLog /var/www/html/www/logs/error.log
CustomLog /var/www/html/www/logs/access.log combined
</VirtualHost>
When this last virtual host is enabled, store.domain.com redirects to www.domain.com

Why doesn't this Apache virtualhost entry work?

I'm running Apache 2.4.6 on Ubuntu 13.
In sites-available, I have a conf file for my site that contains only this:
<VirtualHost *:80>
# Admin email, Server Name (domain name), and any aliases
ServerAdmin somebody#somewhere.com
ServerName www.ourco.me
ServerAlias ourco.me
# Index file and Document Root (where the public files are located)
DirectoryIndex index.html index.php
DocumentRoot /home/ouruser/public/ourco.me/public
# Log file locations
LogLevel warn
ErrorLog /home/ouruser/public/ourco.me/log/error.log
CustomLog /home/ouruser/public/ourco.me/log/access.log combined
</VirtualHost>
There are no other conf files enabled. When I have use apachectl -S to display the sites, it shows:
VirtualHost configuration:
*:80 is a NameVirtualHost
default server www.ourco.me (/etc/apache2/sites-enabled/ourco.me.conf:1)
port 80 namevhost www.ourco.me (/etc/apache2/sites-enabled/ourco.me.conf:1)
alias ourco.me
port 80 namevhost www.ourco.me (/etc/apache2/sites-enabled/ourco.me.conf:1)
alias ourco.me
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex watchdog-callback: using_defaults
Mutex default: dir="/var/lock/apache2" mechanism=fcntl
Mutex mpm-accept: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33
Group: name="www-data" id=33
The first thing I notice is the duplicate entry for namevhost www.ourco.me. And when I visit the site in a browser, I get:
You don't have permission to access / on this server.
Apache/2.4.6 (Ubuntu) Server at www.ourco.me Port 80
All the directories and files specified in the conf file exist. a2ensite and a2dissite work as expected to add/remove a symlink for this file from sites-enabled, so it's looking at the right file. Does anyone know why its directives are being ignored? Thanks.
Put Allow from all
<VirtualHost *:80>
# Admin email, Server Name (domain name), and any aliases
ServerAdmin somebody#somewhere.com
ServerName www.ourco.me
ServerAlias ourco.me
# Index file and Document Root (where the public files are located)
DirectoryIndex index.html index.php
DocumentRoot /home/ouruser/public/ourco.me/public
# Log file locations
LogLevel warn
ErrorLog /home/ouruser/public/ourco.me/log/error.log
CustomLog /home/ouruser/public/ourco.me/log/access.log combined
Allow from all
</VirtualHost>
This appears to solve the problem:
<Directory />
Require all granted
</Directory>
when placed in the VirtualHost entry.
That snippet came from this post. I'm looking at this Apache doc to see why it works.