Category Archives: Apache

SSL tutorials

Just bought a SSL certificate for one of my clients….
Here are some useful tutorial links.—

CSR Generation: Using OpenSSL (Apache w/mod_ssl, NGINX, OS X)
https://support.comodo.com/index.php?/Default/Knowledgebase/Article/View/1/66/

Nginx CSR Generation using OpenSSL
https://support.comodo.com/index.php?/Default/Knowledgebase/Article/View/801/0/nginx-csr-generation-using-openssl

Certificate Installation: Apache & mod_ssl
https://support.comodo.com/index.php?/Default/Knowledgebase/Article/View/637/66/

Certificate Installation : NGINX
https://support.comodo.com/index.php?/Default/Knowledgebase/Article/View/1091/0/certificate-installation–nginx

500 Internal Server Error while uploading files

I was having a 500 Internal Server Error…
nginx logs were showing me the following

2016/03/17 12:09:32 [crit] 31488#0: *11192 open() "/var/lib/nginx/tmp/client_body/0000000005" failed (13: Permission denied), client: 84.91.XXX.XXX, server: host.com, request: "POST /trades_edit/edit_trade HTTP/1.1", host: "host.com", referrer: "https://host.com/trades_edit/125"

Solution?

chown -R www-data:www-data /var/lib/nginx

CloudFlare Apache Module – Ubuntu 14.04 LTS

If we have CloudFlare active on the domain/subdomain that is protected with IP *validation* we need to install libapache2-mod-cloudflare, so Apache can see the real visitor IP, other way it will see the CloudFlare IP, and we wont be able to access the sub/domain.

authz-error

Step 1

echo 'deb http://pkg.cloudflare.com/ trusty main' | sudo tee /etc/apt/sources.list.d/cloudflare-main.list

Step 2

curl -C - https://pkg.cloudflare.com/pubkey.gpg | sudo apt-key add -

Step 3

sudo apt-get update

Step 4

grep ^Package: /var/lib/apt/lists/pkg.cloudflare.com_dists_trusty_main_binary-amd64_Packages

Step 5

sudo apt-get install libapache2-mod-cloudflare

Step 6

sudo service apache2 restart

 

scaleway-libapache2-mod-cloudflare

 

 

Apache 2.4 – allow specific IP

Simple Apache 2.4 configuration to allow a specific IP address to access the sub/domain.

<VirtualHost *:80>
 ServerAdmin [email protected]

 ServerName admin.something.pt
 DocumentRoot /home/webroot/tools/public/

 ErrorLog /home/webroot/tools/logs/error.log
 CustomLog /home/webroot/tools/logs/access.log combined

 <Directory /home/webroot/tools/public/>
 Options Indexes FollowSymLinks MultiViews
 AllowOverride All
 Require ip XXX.XXX.XXX.XXX
 </Directory>
</VirtualHost>

Force www on a domain with apache

This is how!
Edit a .conf (in my case I have a redirects.conf) for this kind of redirects….

nano /etc/apache2/sites-enabled/redirects.conf

And add the following lines…

<VirtualHost *:80>
    ServerName example.com
    Redirect permanent / http://www.example.com/
</VirtualHost>

and naturally restart apache! 😉

service apache2 restart