Home > Mobile >  Reverse Proxy for Django App 404 Not Found
Reverse Proxy for Django App 404 Not Found

Time:01-31

I am following this guide to try show this url www.mycompany.com/testblog instead of www.mycompany.com:8000/testblog

These are my current config files setup inside my website.comssl.conf file

<VirtualHost *:80>

ServerAdmin webmaster@localhost
ServerName website.com
ServerAlias www.website.com
DocumentRoot /var/www/website.com
Redirect permanent / https://website.com/
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

`

<VirtualHost *:443>

ServerAdmin webmaster@localhost
ServerName website.com
ServerAlias www.website.com
DocumentRoot /var/www/website.com
SSLEngine on 
    SSLCertificateFile /etc/ssl/certs/website.com.cer 
    SSLCertificateKeyFile /etc/ssl/private/website.com.key
    SSLCertificateChainFile /var/www/website.com/SSLCert/SSLIntermediateCertificate.cer

ProxyPreserveHost On

    ProxyPass /testblog https://website.com:8000/testblog
    ProxyPassReverse /testblog https://website.com:8000/testblog
</VirtualHost>

However, when I run my server and try to access the URL www.mycompany.com/testblog I get a 404 Not Found error

CodePudding user response:

Have you load proxy module

On Centos/RedHat

$> grep -R "mod_proxy" /etc/httpd/conf.modules.d/
.....
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
.....

On Ubuntu

$> a2enmod proxy
$> a2enmod proxy_http

CodePudding user response:

ProxyPass /testblog https://website.com:8000/testblog

ProxyPassReverse /testblog https://website.com:8000/testblog

This is very uncommon to do for two reasons:

  • Normally you reverse proxy stuff that's not available via public domain name. Often it runs on the same machine or on another machine in the same network. In this case, use the IP instead (127.0.0.1 for the local machine or the IP shown in ip addr command on the other machine)
  • You're using https: but backend services are normally not SSL protected. Also port 8000 is very uncommon for SSL.

In other words, are you sure you want this and not ProxyPass /testblog http://127.0.0.1:8000/testblog

  • Related