Category Archives: Apache

CentOS – Enable the mod_proxy modules in the HTTPD

In our /etc/httpd/conf/httpd.conf lets see if we have the following lines on it.
Uncomment them or add them.

  1. LoadModule proxy_module modules/mod_proxy.so
    LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
    LoadModule proxy_http_module modules/mod_proxy_http.so
    # Uncomment these to proxy FTP or HTTPS
    #LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
    #LoadModule proxy_connect_module modules/mod_proxy_connect.so
    

 

apache – proxy & proxy_http

 

Invalid command ‘ProxyPreserveHost’, perhaps misspelled or defined by a module not included in the server configuration

sudo a2enmod proxy

 

[Sun Feb 26 03:48:38.613627 2017] [proxy:warn] [pid 9117] [client 94.63.XXX.XXX:49486] AH01144: No protocol handler was valid for the URL /. If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule.

sudo a2enmod proxy_http

Restart apache and everything should be okay now.
HOORAY!

.htaccess: Invalid command ‘ExpiresActive’ and .htaccess: Invalid command ‘Header’

 

.htaccess: Invalid command ‘ExpiresActive’, perhaps misspelled or defined by a module not included in the server configuration,
ln -s /etc/apache2/mods-available/expires.load /etc/apache2/mods-enabled/
.htaccess: Invalid command ‘Header’, perhaps misspelled or defined by a module not included in the server configuration
a2enmod headers

At the end… restart Apache!

service apache2 restart

How to get a Let’s Encrypt certificate while using CloudFlare

 

How to get a Let’s Encrypt certificate while using CloudFlare

./certbot-auto certonly --webroot --webroot-path /usr/share/nginx/html/ --renew-by-default --email [email protected] --text --agree-tos -d example.tld -d www.example.tld

Cloudflare – ban country with .htaccess

One of my clients asked me to BAN an specific country to one of his sites.
Since we have Cloudflare, this is how I made it…

On .htaccess I’v simply added the following lines – on the top of .htaccess -.

SetEnvIf CF-IPCountry IN BuzzOff=1
SetEnvIf CF-IPCountry PT BuzzOff=1
Order allow,deny
Allow from all
Deny from env=BuzzOff

But remember!
Domain/subdomain must have Cloudflare active on DNS settings…

Negotiation: discovered file(s) matching request

 

AH00687: Negotiation: discovered file(s) matching request: /home/httpd/html/domain.com/public_html/login (None could be negotiated)., referer: http://www.domain.com/

Under the domain.com.conf I had

Options Indexes FollowSymLinks MultiViews

The solution is to remove MultiViews from it.

Options Indexes FollowSymLinks

 

Source: http://www.bennadel.com/blog/2218-negotiation-discovered-file-s-matching-request-none-could-be-negotiated.htm

discourse – htpasswd protected

discour-apache-htpasswd

I have client who *needs* discourse under a subdomain that should be only accessed by users who have a valid username & password in a .htpasswd….
Since discourse doesn’t use Apache I had to implement Apache ProxyPass  to solve this ‘issue’…

This is how it looks…

<VirtualHost *:80>

 ServerName social.subdomain.com

 ProxyPreserveHost Off
 ProxyPass / http://192.241.XXX.XX/
 ErrorLog /data/logs/discourse_error.log

 <Location />
   AuthType Basic
   AuthName "Only for members"
   AuthBasicProvider file
   AuthUserFile "/path/to/.htpasswd"
   Require valid-user
 </Location>

</VirtualHost>

This might not be the best solution….. comments are appreciated! 🙂