Looking to redirect path /blog to another server using Apache - 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

Related

SOLVED: How to configure Apache2 with Reverse Proxy. Map an internal website to a folder of another (public) website on the same server

I have build a SPA and deployed it to my server. It is running on http://my-server:3000.
I then installed Apache2 and created a static page. This website is on the same server http://my-server:80 and is open to the Internet via a My-domain.
What I'm trying to accomplish now is to add a link on this static page (http://my-server/foo) which is redirected to http://my-server:3000 in such a way that the here deployed SPA can be run from this sub-folder.
I configured a new Virtual host in Apache2 with the following configuration:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName My-domain
ProxyRequests Off
ProxyHTMLEnable On
ProxyHTMLExtended Off
ProxyPreserveHost On
ProxyPass /foo/ http://my-server:3000/
<Location /foo/>
ProxyHTMLURLMap / /foo/
ProxyPassReverse http://my-server:3000/
SetOutputFilter INFLATE;DEFLATE
</Location>
<Proxy *>
Order allow,deny
Allow from all
</Proxy>
LogLevel info
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Although the SPA is accessed and all the files are loaded the application will not start due to the error No match for URL in routes. I think it is due to the fact that the SPA is build to run in the root of a website and I'm now trying to run it in a sub-folder.
Does anyone know if this is possible? A solution would be appreciated much :-)
I found a solution which works for me :-)
Since I can use any prefix before My-domain like foo.My-domain, just found out recently, I changed the configuration for my Virtual host to this:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName foo.My-domain
ProxyRequests Off
ProxyHTMLEnable On
ProxyHTMLExtended Off
ProxyPreserveHost On
ProxyPass / http://my-server:3000/
<Location />
ProxyPassReverse http://my-server:3000/
SetOutputFilter INFLATE;DEFLATE
</Location>
<Proxy *>
Order allow,deny
Allow from all
</Proxy>
LogLevel info
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
And because my SPA now is allowed to run in the root of a website it is working. :-)

Apache Reverse proxy is throwing 404 error

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

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>

Try to add a VirtualHost

I have a web server with a website and i want to add another address for pre-production use.
Here the existant:
httpd.conf:
ServerAdmin support#toto.com
ServerName www.toto.com:80
DocumentRoot "/home/tutu/var/www/html"
modules/vhost.conf:
<VirtualHost *:80>
ServerAdmin support#toto.com
ServerName www.toto.com:80
DirectoryIndex index.php
ErrorLog /home/tutu/var/log/httpd/error-mod_log
LogLevel warn
CustomLog /home/tutu/var/log/httpd/access-mod_log common-cookie
<Location /server-status>
SetHandler server-status
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Location>
</VirtualHost>
And I have tried to add another VirtualHost but the new address not working:
<VirtualHost *:80>
ServerAdmin support#toto.com
ServerName www2.toto.com:80
DirectoryIndex index.php
ErrorLog /home/tutu/var/log/httpd/error-www2_log
LogLevel warn
CustomLog /home/tutu/var/log/httpd/access-www2_log common-cookie
DocumentRoot "/home/tutu/var/www2/html"
</VirtualHost>
The address www2.toto.com is not working.
Have you an idea?
Thanks
Have you added www2.toto.com to DNS?
It's not added to public DNS yet. (But www.toto.com is)
"Not working" is not very specific. Do you get the default Apache web-page for that site or do you not reach the server? If it's the latter, DNS lookup is likely your real problem, not the Apache config.
The Apache-config looks good, but you should not need to specify :80 as the alias port.