Archive | Apache RSS feed for this section

Generate CSR with single command

Here’s a single command to generate a new key and CSR: openssl req -nodes -newkey rsa:2048 -keyout mydomain.key -out mydomain.csr Bookmark on Delicious Digg this post Recommend on Facebook share via Reddit Share with Stumblers Tweet about it Subscribe to the comments on this post Print for later Bookmark in Browser Tell a friend

Here’s a single command to generate a new key and CSR:

openssl req -nodes -newkey rsa:2048 -keyout mydomain.key -out mydomain.csr
View Comments Continue Reading →

Canonical Rewrite Rule For Nginx

Need to redirect from acme.com to www.acme.com with nginx? No problem … just add a virtual host declaration for the non-www that redirects like this: server { listen 80; server_name acme.com; rewrite ^/(.*) http://www.acme.com/$1 permanent; } Bookmark on Delicious Digg this post Recommend on Facebook share via Reddit Share with Stumblers Tweet about it Subscribe [...]

Need to redirect from acme.com to www.acme.com with nginx? No problem … just add a virtual host declaration for the non-www that redirects like this:

server {
  listen 80;
  server_name acme.com;
  rewrite ^/(.*) http://www.acme.com/$1 permanent;
}
View Comments Continue Reading →

Canonical Rewrite Rules

Here’s a good rule set for forcing use of a preferred url: RewriteCond %{HTTP_HOST} !^desired\.domain\.name(:.*)?$ [NC] RewriteCond %{HTTP_HOST} !^$ RewriteRule ^/?(.*) http://desired.domain.name/$1 [L,R=301] This version of the canonical rewrite expands on the original found here: http://httpd.apache.org/docs/2.2/rewrite/rewrite_guide.html#canonicalhost by adding: redirects domains with suffixes (not just prefixes) back to the canonical host; and allows Host request headers [...]

Here’s a good rule set for forcing use of a preferred url:

RewriteCond %{HTTP_HOST} !^desired\.domain\.name(:.*)?$  [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/?(.*) http://desired.domain.name/$1 [L,R=301] 

This version of the canonical rewrite expands on the original found here:

http://httpd.apache.org/docs/2.2/rewrite/rewrite_guide.html#canonicalhost

by adding:

  1. redirects domains with suffixes (not just prefixes) back to the canonical host; and
  2. allows Host request headers to contain port specifiers (which is allowed by RFC2616 section 14.24)

as suggested here:

http://colby.id.au/node/99

and by using a 301 redirect as recommended by Google here:

http://www.google.com/support/webmasters/bin/answer.py?answer=44231&hl=en

View Comments Continue Reading →

Setting Apache umask

Problem was that uploaded files were being assigned permissions of 0600 which is “-rw——-”. The webserver was then unable to service the files. The “0600″ permissions corresponds to a umask of “066″. Instead I wanted “022″ which would yield “-rw-rw-r–” or “0664″. On Ubuntu, edit /etc/apache2/envvars and add this line to the end of the [...]

Problem was that uploaded files were being assigned permissions of 0600 which is “-rw——-”. The webserver was then unable to service the files. The “0600″ permissions corresponds to a umask of “066″. Instead I wanted “022″ which would yield “-rw-rw-r–” or “0664″.

On Ubuntu, edit /etc/apache2/envvars and add this line to the end of the file:

umask 022

On Red Hat/CentOS do this:

echo "umask 002" >> /etc/sysconfig/httpd

Now restart Apache and the new umask will be in effect.

View Comments Continue Reading →

IP Based Authorization on Apache With NGINX Proxy

In the nginx config add: proxy_set_header X-Real-IP $remote_addr; In the apache config add: SetEnvIf X-Real-IP 72.3.230.* is_admin=true Allow from env=is_admin Bookmark on Delicious Digg this post Recommend on Facebook share via Reddit Share with Stumblers Tweet about it Subscribe to the comments on this post Print for later Bookmark in Browser Tell a friend

In the nginx config add:

proxy_set_header X-Real-IP $remote_addr;

In the apache config add:

SetEnvIf X-Real-IP 72.3.230.* is_admin=true
Allow from env=is_admin

View Comments Continue Reading →