Posts

Showing posts with the label apache2

vim /etc/apache2/sites-enabled/default-ssl.conf

Image
  Apache base virtual host file, default ssl conf file. Vim  /etc/apache2/sites-enabled/default-ssl.conf : <IfModule mod_ssl.c >     <VirtualHost  xxx.xx.xxx.xxx:443 >         ServerName jobsite.com         ServerAlias *.jobsite.com         LogLevel debug         ErrorLog /var/log/apache2/jobsite_com_error.log         CustomLog /var/log/apache2/jobsite_com_custom.log combined         SSLEngine on         SSLCertificateFile /etc/ssl/jobsite_com/jobsite_com.crt         SSLCertificateKeyFile /etc/ssl/jobsite_com/jobsite_com.key         # SSLCertificateChainFile /etc/ssl/jobsite_com/intermediate.crt         RewriteEngine On         RewriteCond %{HTTPS} off [OR]         RewriteCond %{HTTP_HOST} ^jobsite\.c...

Invalid HTTP_HOST header: '.your-domain.com'. The domain name provided is not valid according to RFC 1034/1035 (You may need to add u'domain.com' to ALLOWED_HOSTS.).

Image
I have several Django projects published and my mailbox and log files are constantly inundated with spider errors and hacking attempts to connect to my applications. These error messages have an email subject: "[Django] ERROR (EXTERNAL IP): Invalid HTTP_HOST ...".  So after spending a long time with this, I solved this problem with Apache (Require). The correct format for "Require" and "SetEnvIfExpr" is: ^[^_]+  would match a string of 1 or more character containing any character except underscore. <VirtualHost  xxx.xxx.xxx.xxx:80 >      ...     SetEnvIfNoCase Host "^[^_]+\.my-domain\.com" VALID_HOST     <Location / >         <RequireAll>             Require all granted             Require env VALID_HOST         </RequireAll>     </Location>     ... </VirtualHost> Or to be more ...