Why is reverse proxy with Apache returning different results? - apache

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

Related

Reverse Proxy not running on HTTPS Apache Server

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.

trying to configure my virtual host files on an apache server for local development on a mac

trying to configure a virtual host for my project however the server automatically picks up the root directory. Below is what i have configured it to be.
<VirtualHost 127.0.0.2:8080> ServerName project-1.local DocumentRoot "/Users/mac/Projects/project-1/public" <Directory "/Users/mac/Projects/project-1/public"> AllowOverride All Require all granted </Directory> </VirtualHost>
However this is what i get when i run apachectl -S
VirtualHost configuration: 127.0.0.2:8080 project-1.local (/usr/local/etc/httpd/extra/httpd-vhosts.conf:40) ServerRoot: "/usr/local/opt/httpd" Main DocumentRoot: "/usr/local/var/www" Main ErrorLog: "/usr/local/var/log/httpd/error_log" Mutex mpm-accept: using_defaults Mutex default: dir="/usr/local/var/run/httpd/" mechanism=default PidFile: "/usr/local/var/run/httpd/httpd.pid" Define: DUMP_VHOSTS Define: DUMP_RUN_CFG User: name="_www" id=70 not_used Group: name="_www" id=70 not_used
What am i doing wrong here?
this is what my hosts file looks like
127.0.0.1 localhost 255.255.255.255 broadcasthost ::1 localhost 127.0.0.2 project-1.local
i tried changing the vhost file and resaving it however it didnt work

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.

Apache Virtualhost on different port redirecting to DefaultRoot

I'm trying to set to virtual hosts listening to different ports with apache 2.4
On port 80: A plain HTML page.
On port 81: An Angular6 app.
On my 0_web.conf
<VirtualHost *:80>
ServerName web
DocumentRoot /var/www/html/web
DirectoryIndex index.html
<Directory /var/www/html/web>
AllowOverride all
</Directory>
</VirtualHost>
On front.conf
Listen 81
<VirtualHost *:81>
ServerName munitdp
<Directory /var/www/dist/>
RewriteEngine on
# Don't rewrite files or directories
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
# Rewrite everything else to index.html
# to allow html5 state links
RewriteRule ^ index.html [L]
</Directory>
</VirtualHost>
I'm using an amazon ec2 server. For now I don't have any domain so i access urls like http://ec2-18-xxx-xxx-xxx.us-west-2.compute.amazonaws.com/
Output of apachectl -S
VirtualHost configuration:
*:80 web (/etc/httpd/conf.d/0_web.conf:1)
*:81 munitdp (/etc/httpd/conf.d/front.conf:2)
ServerRoot: "/etc/httpd"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/etc/httpd/logs/error_log"
Mutex proxy: using_defaults
Mutex authn-socache: using_defaults
Mutex default: dir="/run/httpd/" mechanism=default
Mutex mpm-accept: using_defaults
Mutex cache-socache: using_defaults
Mutex authdigest-opaque: using_defaults
Mutex watchdog-callback: using_defaults
Mutex proxy-balancer-shm: using_defaults
Mutex rewrite-map: using_defaults
Mutex authdigest-client: using_defaults
Mutex lua-ivm-shm: using_defaults
PidFile: "/run/httpd/httpd.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="apache" id=48
Group: name="apache" id=48
When I enter http://ec2-18-xxx-xxx-xxx.us-west-2.compute.amazonaws.com/ I get to the html page, but accesing http://ec2-18-xxx-xxx-xxx.us-west-2.compute.amazonaws.com:81 gets me to "Index of /", listing web/.
Any ideas? I've been hitting a wall here.
I dont see a DocumentRoot defined in the second vHost. Maybe add
DocumentRoot /var/www/dist/
to your front.conf

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