Apache Reverse proxy is throwing 404 error - apache

I am using apache2 for my reverse proxy but it keeps on throwing 404 for my setup
<VirtualHost *:80>
ServerAdmin admin#domain.com
ServerName domain.com
ServerAlias www.domain.com
ProxyPreserveHost On
ProxyRequests Off
ProxyPass / http://localhost:7201/
ProxyPassReverse / http://localhost:7201/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Please do lemme know if there is something I can fix it in my setup. Thanks :)

Please change the port.
go to apache server.
config
httpd.conf
find and replace
80 and 8080 or 90 enter code here's you want

Related

Apache: two domains on the same server with different ports

I'm newbie on this stuff so forgive me if i'm doing a stupid question. I have a vue application running on port 80 working just fine over SSL (say www.domain.com and domain.com).
Now I need my springboot application, which is running over port 8443 to be accessible by a secure connection too (say on api.domain.com) but i can't quite figure what i'm doing wrong...
I can access the api if i'm not including the second virtualhost, but only using http... Also, when I just type api.domain.com it goes to domain.com start page too. And when I include the second virtualhost, I can't even acces domain.com.
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
ServerName www.domain.com
Include /etc/letsencrypt/options-ssl-apache.conf
ServerAlias domain.com
ProxyPreserveHost On
SSLCertificateFile /etc/letsencrypt/live/domain.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/domain.com/privkey.pem
</VirtualHost>
<VirtualHost *:443>
ServerAdmin webmaster#localhost
ServerName api.domain.com
Include /etc/letsencrypt/options-ssl-apache.conf
ServerAlias api.domain.com
SSLCertificateFile /etc/letsencrypt/live/domain.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/domain.com/privkey.pem
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:8443/
ProxyPassReverse / http://127.0.0.1:8443/
</VirtualHost>
</IfModule>
Found it out: there are some apache modules that need to be activated. Just did it with
sudo a2enmod proxy
sudo a2enmod proxy_http
and everything works like a charm.

Apache2 VirtualHost SSL config issues

Debian 10 / Apache2 -
GOAL: redirect all web traffic to VPS server to SSL. I have 2 sites hosted: bjmurrey.com and nextcloud.bjmurrey.com. I have 1 IP address.
PROBLEM: I can't for the life of me find a way to make this work. I have tried 1000 suggestions posted here and elsewhere with no success. The closest I get is everything redirects to https://bjmurrey.com when typing in nextcloud.bjmurrey.com. I am also a novice at this so please be kind.
I have a default.conf that looks like this:
<VirtualHost *:80>
ServerName www.bjmurrey.com
ServerAlias bjmurrey.com
DocumentRoot /var/www/blog
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Redirect permanent / https://bjmurrey.com/
</VirtualHost>
<VirtualHost *:80>
ServerName nextcloud.bjmurrey.com
DocumentRoot /var/www/nextcloud
ServerAlias nextcloud.bjmurrey.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Redirect permanent / https://nextcloud.bjmurrey.com/
</VirtualHost>
I have a default-ssl.conf that looks like this:
<VirtualHost bjmurrey.com:443>
ServerName bjmurrey.com
ServerAlias www.bjmurrey.com
DocumentRoot /var/www/blog
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/bjmurrey.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/bjmurrey.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
<VirtualHost nextcloud.bjmurrey.com:443>
ServerName nextcloud.bjmurrey.com
DocumentRoot /var/www/nextcloud
ServerAlias nextcloud.bjmurrey.com
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/nextcloud.bjmurrey.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/nextcloud.bjmurrey.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
bjmurrey.com is in var/www/blog and nextcloud.bjmurrey.com in the var/www/nextcloud directories.
I have my DNS records www and nextcloud both pointed to same IP. I only have 1 IP available. This is a very low traffic site.
I have done all kinds of things like just have the default virtual host redirect to only nextcloud and removed all mention of the www site and it still redirects to bjmurrey.com, or redirects with an SSL error saying that nextcloud can't be loaded because the ssl is for bjmurrey.com only. As you can see I have made certs with letsencrypt for both bjmurrey.com and nextcloud.bjmurrey.com.
I'm about to yank all my hair out in frustration, so I know I've tapped out all my knowledge here. Help!
I have retested with http and is working for me.
Both addresses mydomain.myhost.example.com and myhost.example.com resolve to the same IP.
This is my configuration file
ServerName example.com
<VirtualHost *:80>
ServerName mydomain.myhost.example.com
DocumentRoot /var/www/mydomain
</VirtualHost>
<VirtualHost *:80>
ServerName myhost.example.com
DocumentRoot /var/www/myhost
</VirtualHost>
Tested in Ubuntu 20.04.1, Apache 2.4

client denied by server configuration: website_c.wsgi, referer: http://website_b.com/

I'm not a sysadmin, but I do my best, so apologies in advance for my ignorance.
I run a linux server with apache2 on it. I have 3 websites I am trying to host on it, but the sites-enabled/000-default.conf file must be misconfigured.
Basically, website_c seems to be preventing website_b from showing up, as per the error message in the title. website_a and website_c show up correctly.
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/ghost
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
ProxyPreserveHost On
# Servers to proxy the connection, or
# List of application servers Usage
ProxyPass / http://localhost:2369/
ProxyPassReverse / http://localhost:2369/
ServerName website_a.com
ServerAlias www.website_a.com
</VirtualHost>
<VirtualHost *:80>
ServerName website_b.com:80
DocumentRoot /var/www/website_b
ServerAlias www.website_b.com
ErrorLog ${APACHE_LOG_DIR}/error.log
</VirtualHost>
<VirtualHost *:80>
ServerName website_c.com:80
ServerAlias .*
WSGIScriptAlias / /home/username/python_envs/production/website_c/apache/production-website_c.wsgi
<Directory /home/username/python_envs/production>
Require all granted
</Directory>
</VirtualHost>
WSGIScriptAlias / /home/username/python_envs/production/website_c/apache/production-website_c.wsgi
WSGIPythonHome /home/username/python_envs/production
WSGIPythonPath /home/username/python_envs/production/website_c
Alias /rgc-dev/static/ /home/username/python_envs/dev/website_c-static/
WSGIScriptAlias /rgc-dev /home/username/python_envs/dev/website_c/apache/dev-website_c.wsgi
Alias /rgc-staging/static/ /home/username/python_envs/staging/website_c-static/
WSGIScriptAlias /rgc-staging /home/username/python_envs/staging/project_container/website_c/apache/staging-website_c.wsgi
Alias /rgc-production/static/ /home/username/python_envs/production/website_c-static/
WSGIScriptAlias /rgc-prod /home/username/python_envs/production/website_c/apache/production-website_c.wsgi
The error message in the apache log when I try to access website_b is: client denied by server configuration: /home/username/python_envs/production/website_c/apache/production-website_c.wsgi, referer: http://website_b.com/
Can anyone spot the issue with my apache conf? Please let me know if you need me to post the production-website_c.wsgi, I can't see anything that looks relevant there.
Thank you!
this was the problem:
WSGIScriptAlias / /home/username/python_envs/production/website_c/apache/production-website_c.wsgi
I commented out that line and website_c was still displaying correctly, so there ya go.

Redirect Apache application to dot net core application

I have a server which uses a domain example.com. I am using apache to run this web server. I have also installed Dot Net core and published a Dot Net core app to /var/www/app location.
I a trying to access this application using example.com/api
This below is what I have tried in 000-default.conf
<VirtualHost *:80>
ServerAdmin root#example.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
the below is what I hvae added for the application
<VirtualHost *:80>
ServerName example.com/api
ProxyPreserveHost On
<Proxy *>
Order allow, deny
Allow from all
</Proxy>
ProxyPass / http://localhost:5000/
ProxyPassReverse / http://localhost:5000/
</VirtualHost>
I have also tried the below configuration.
<VirtualHost *:80>
ServerName example.com/api
redirect / http://localhost:5000/
</VirtualHost>
can someone please help me find what am I doing wrong and how to achieve this properly.
This is solved by enabling proxy and proxy_http using commands below.
a2enmod proxy
a2enmod proxy_http
Also configured the Proxy inside the virtual host as follows.
<VirtualHost *:80>
ServerAdmin root#example.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/html
#Below 3 lines worked
ProxyPreserveHost On
Proxypass "/api/" "http://localhost:5000/"
ProxyPassReverse "/api/" "http://localhost:5000/"
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Looking to redirect path /blog to another server using Apache

I want to host my blog on it's own server, but have the URL be at mysite.com/blog
Should I do this using mod_proxy or an apache redirect, and how would I set this up on apache?
My first pass attempt looks like so in the vhost file, but failed:
<VirtualHost *:80>
ProxyPreserveHost On
ProxyPass /blog http://blog.server's.ip.address/
ProxyPassReverse /blog http://blog.server's.ip.address/
ServerAdmin me#myemail.com
ServerName mysite.com
DocumentRoot /var/www
<Directory /var/www>
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
With this is place I get the following error when restarting apache:
Restarting web server apache2 /sbin/start-stop-daemon: warning: failed to kill 11306: Operation not permitted
[fail]
The apache2 configtest failed, so we are trying to kill it manually. This is almost certainly suboptimal, so please make sure your system is working as you'd expect now!
mod_proxy needs to be enabled before working >_<
Once I enabled it my config worked as expected.
a2enmod proxy_http
<VirtualHost *:80>
ProxyPreserveHost On
ProxyPass /blog http://server4.hostinger.co.uk.ip.31.170.164.19/
ProxyPassReverse /blog http://server4.hostinger.co.uk.ip.31.170.164.19/
ServerAdmin http://webmail.hostinger.co.uk
ServerName armukul.com.ip address 31.170.164.123 domain ip ("A" DNS record) to this IP: 31.170.164.123
DocumentRoot /var/www.armukul.com/home/u311366417
<Directory /var/www>armukul.com
Order allow,deny
allow from all
</Directory>www>armukul.net
</Directory>www>facebook.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>[][1]
[1]: http://armukul.com/home