User Tools

Site Tools


server_installation:nginx_proxy

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Last revisionBoth sides next revision
server_installation:nginx_proxy [2009/10/04 01:29] – created nginx documentation dbsserver_installation:nginx_proxy [2009/12/14 13:51] aatre
Line 1: Line 1:
 ====== Using nginx to serve static content ====== ====== Using nginx to serve static content ======
 +**Warning**: While this seems to work well for the dynamic catalogue, there are known problems using a reverse proxy (such as nginx) with the basic catalogue/SlimPAC/SuperCat. Work needs to be done to prevent hostname/port from being set incorrectly for generated links in these pages.
 +
 A default Evergreen install uses Apache to serve up both static and dynamic content. This causes Apache to have to constantly respawn backend processes. Using a high-performance proxy server to serve up static content and pass on the dynamic requests to Apache can make you, your server, and your users happier. The following document is based on a full handful of late-night hours trying out nginx for the first time, so use at your own risk... A default Evergreen install uses Apache to serve up both static and dynamic content. This causes Apache to have to constantly respawn backend processes. Using a high-performance proxy server to serve up static content and pass on the dynamic requests to Apache can make you, your server, and your users happier. The following document is based on a full handful of late-night hours trying out nginx for the first time, so use at your own risk...
  
Line 5: Line 7:
 <ol> <ol>
 <li>Install nginx: <tt>sudo aptitude install nginx</tt></li> <li>Install nginx: <tt>sudo aptitude install nginx</tt></li>
-<li>Copy the configuration file (below), changing "192.168.69.107" to match your server's IP address or host name, into a file called <tt>/etc/nginx/sites-available/evergreen</tt> and create a symbolic link to the file at <tt>/etc/nginx/sites-enabled/evergreen</tt></li>+<li>Copy the configuration file (below) into a file called <tt>/etc/nginx/sites-available/evergreen</tt> and create a symbolic link to the file at <tt>/etc/nginx/sites-enabled/evergreen</tt></li> 
 +<li>Modify the nginx configuration file server_name directive to match all the names of your virtual hosts, ssl certificate information and check gzip_disable comment</li>
 <li>Modify <tt>/etc/apache2/ports.conf</tt> to change port 80 to 9080 and port 443 to 9443.</li> <li>Modify <tt>/etc/apache2/ports.conf</tt> to change port 80 to 9080 and port 443 to 9443.</li>
 <li>Modify <tt>/etc/apache2/eg_vhost.conf</tt> to change the "Listen 443" directive to "Listen 9443"</li> <li>Modify <tt>/etc/apache2/eg_vhost.conf</tt> to change the "Listen 443" directive to "Listen 9443"</li>
 +<li>Modify <tt>/etc/apache2/sites-available/eg.conf</tt> to change port 80 to 9080 and port 443 to 9443.</li>
 <li>Restart nginx and Apache to put the new configuration in place</li> <li>Restart nginx and Apache to put the new configuration in place</li>
 +<li>Enable ports 9080 and 9443 if required in your firewall</li>
 <li>Enjoy!</li> <li>Enjoy!</li>
 </ol></html> </ol></html>
-<code> +<code>server { 
-# Change "192.168.69.107" throughout to match your server's host name or IP address+        listen 80; 
 +        server_name test.concat.ca js-test.concat.ca css-test.concat.ca images-test.concat.ca;
  
-server { 
-        listen 192.168.69.107:80; 
- 
-        server_name 192.168.69.107; 
         root /openils/var/web;         root /openils/var/web;
  
Line 36: Line 38:
                 proxy_pass http://localhost:9080;                 proxy_pass http://localhost:9080;
                 proxy_redirect off;                 proxy_redirect off;
 +                port_in_redirect off;
 +
 +                if ($request_uri ~* "\.(ico|css|js|gif|jpe?g|png)$") {
 +                        expires 31d;
 +                        break;
 +                }
 +
         }         }
 +
 +        # Enable compression of content
 +        gzip on;
 +
 +        # IE 6 doesn't deal well with gzipped pages.
 +        # You may disable this feature if you are
 +        # running nginx 0.6.23 or higher (nginx -V)
 +        # by uncommenting the line below.
 +        # gzip_disable "MSIE [1-6]\.";
 +
 +        # Compress proxied content as well - enables XML / XUL files 
 +        # to be compressed after XMLENT has had its way with them
 +        gzip_proxied any;
 +
 +        # By default, nginx only compresses text/html
 +        gzip_types text/html text/plain text/xml text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;
 +
 +        # Ensure that large content (the most important stuff) can be compressed
 +        gzip_buffers 16 8k;
  
 } }
  
 server { server {
-        listen 192.168.69.107:443; +        listen 443; 
-        server_name 192.168.69.107;+        server_name test.concat.ca js-test.concat.ca css-test.concat.ca images-test.concat.ca; 
         root /openils/var/web;         root /openils/var/web;
  
         ssl on;         ssl on;
-        ssl_certificate /etc/apache2/ssl/server.crt; +        ssl_certificate /etc/apache2/ssl/*.concat.ca.crt; 
-        ssl_certificate_key /etc/apache2/ssl/server.key;+        ssl_certificate_key /etc/apache2/ssl/*.concat.ca.key;
  
         access_log /var/log/nginx/evergreen_ssl.access.log;         access_log /var/log/nginx/evergreen_ssl.access.log;
Line 65: Line 94:
                 proxy_pass https://localhost:9443;                 proxy_pass https://localhost:9443;
                 proxy_redirect off;                 proxy_redirect off;
 +                port_in_redirect off;
 +
 +                if ($request_uri ~* "\.(ico|css|js|gif|jpe?g|png)$") {
 +                        expires 31d;
 +                        break;
 +                }
 +
         }         }
 +
 +        # Enable compression of content
 +        gzip on;
 +
 +        # IE 6 doesn't deal well with gzipped pages.
 +        # You may disable this feature if you are
 +        # running nginx 0.6.23 or higher (nginx -V)
 +        # by uncommenting the line below.
 +        # gzip_disable "MSIE [1-6]\.";
 +
 +        # Compress proxied content as well - enables XML / XUL files 
 +        # to be compressed after XMLENT has had its way with them
 +        gzip_proxied any;
 +
 +        # By default, nginx only compresses text/html
 +        gzip_types text/html text/plain text/xml text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;
 +
 +        # Ensure that large content (the most important stuff) can be compressed
 +        gzip_buffers 16 8k;
 } }
 </code> </code>
 +**External Reference Links:**
  
 + [[http://wiki.nginx.org/NginxHttpGzipModule#gzip_disable]]
 + [[http://wiki.nginx.org/]]

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki

© 2008-2022 GPLS and others. Evergreen is open source software, freely licensed under GNU GPLv2 or later.
The Evergreen Project is a U.S. 501(c)3 non-profit organization.