Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

May 162011
 

Why SSL cannot be used with name-based virtual hosts?

Answer:

The reason is pretty simple: If you are using a single IP but with many virtual hosts, each virtual hosts has their own certificate and private key. Without looking at the Host header in the incoming HTTP request, Apache will not be able to route the request to the designated virtual hosts. The core problem is, the incoming requests are encrypted so we are not able to tell which key should be used for decryption!

So only IP-based virtual hosts works if you need SSL.

Apr 302011
 

Enable Expire header in Nginx

Answer:

Enabling Expire header for static contents is useful to reduce the loading of your web server.

If you are using nginx, it is easy by adding the following lines in your nginx.conf

location ~* \.(ico|css|js|gif|jpe?g|png)$ {
    expires max;
}

So all files with the above extensions will be delivered with the maximum expire header.

If you want user to update the cached contents, make sure you have change the path (i.e. rename) of these resources.

Dec 172010
 

How to change the nginx log format?

Answer:

Firstly, you need to define a valid log format for nginx, e.g.

log_format foo '$remote_addr - $remote_user [$time_local]  '
                '"$request" $status $bytes_sent '
                '"$http_referer" "$http_user_agent"';

Then, you need to link that format with your log file:

access_log /var/logs/nginx-test-access.log foo;

Aug 142010
 

Enable gzip compression in Nginx

Answer:

Enabling gzip compression for text based output such as HTML can greatly improve the response of user.

If you are using nginx, it is easy by adding the following lines in your nginx.conf

gzip  on;
gzip_min_length  1000;
gzip_proxied     expired no-cache no-store private auth;
gzip_types text/plain text/html text/css application/json application/x-javascript text/javascript text/xml application/xml;
Apr 102010
 

Installing Nginx in Ubuntu

Answer:

1. Using aptitude

# sudo aptitude install nginx

2. Start it

# sudo /etc/init.d/nginx start

3. Stop it

# sudo /etc/init.d/nginx stop

4. Restart it

# sudo /etc/init.d/nginx restart