docs/nginx.sample.conf
author indvdum (gotoindvdum[at]gmail[dot]com)
Wed, 07 Mar 2012 16:41:10 +0400
changeset 0 ceef6d64c21d
permissions -rw-r--r--
Added phpBB-3.0.10
indvdum@0
     1
# Sample nginx configuration file for phpBB.
indvdum@0
     2
# Global settings have been removed, copy them
indvdum@0
     3
# from your system's nginx.conf.
indvdum@0
     4
# Tested with nginx 0.8.35.
indvdum@0
     5
indvdum@0
     6
http {
indvdum@0
     7
    # Compression - requires gzip and gzip static modules.
indvdum@0
     8
    gzip on;
indvdum@0
     9
    gzip_static on;
indvdum@0
    10
    gzip_vary on;
indvdum@0
    11
    gzip_http_version 1.1;
indvdum@0
    12
    gzip_min_length 700;
indvdum@0
    13
    
indvdum@0
    14
    # Compression levels over 6 do not give an appreciable improvement
indvdum@0
    15
    # in compression ratio, but take more resources.
indvdum@0
    16
    gzip_comp_level 6;
indvdum@0
    17
    
indvdum@0
    18
    # IE 6 and lower do not support gzip with Vary correctly.
indvdum@0
    19
    gzip_disable "msie6";
indvdum@0
    20
    # Before nginx 0.7.63:
indvdum@0
    21
    #gzip_disable "MSIE [1-6]\.";
indvdum@0
    22
indvdum@0
    23
    # Catch-all server for requests to invalid hosts.
indvdum@0
    24
    # Also catches vulnerability scanners probing IP addresses.
indvdum@0
    25
    server {
indvdum@0
    26
        # default specifies that this block is to be used when
indvdum@0
    27
        # no other block matches.
indvdum@0
    28
        listen 80 default;
indvdum@0
    29
indvdum@0
    30
        server_name bogus;
indvdum@0
    31
        return 444;
indvdum@0
    32
        root /var/empty;
indvdum@0
    33
    }
indvdum@0
    34
indvdum@0
    35
    # If you have domains with and without www prefix,
indvdum@0
    36
    # redirect one to the other.
indvdum@0
    37
    server {
indvdum@0
    38
        # Default port is 80.
indvdum@0
    39
        #listen 80;
indvdum@0
    40
indvdum@0
    41
        server_name myforums.com;
indvdum@0
    42
indvdum@0
    43
        # A trick from http://wiki.nginx.org/Pitfalls#Taxing_Rewrites:
indvdum@0
    44
        rewrite ^ http://www.myforums.com$request_uri permanent;
indvdum@0
    45
        # Equivalent to:
indvdum@0
    46
        #rewrite ^(.*)$ http://www.myforums.com$1 permanent;
indvdum@0
    47
    }
indvdum@0
    48
indvdum@0
    49
    # The actual board domain.
indvdum@0
    50
    server {
indvdum@0
    51
        #listen 80;
indvdum@0
    52
        server_name www.myforums.com;
indvdum@0
    53
indvdum@0
    54
        root /path/to/phpbb;
indvdum@0
    55
indvdum@0
    56
        location / {
indvdum@0
    57
            # phpbb uses index.htm
indvdum@0
    58
            index index.php index.html index.htm;
indvdum@0
    59
        }
indvdum@0
    60
indvdum@0
    61
        # Deny access to internal phpbb files.
indvdum@0
    62
        location ~ /(config\.php|common\.php|includes|cache|files|store|images/avatars/upload) {
indvdum@0
    63
            deny all;
indvdum@0
    64
            # deny was ignored before 0.8.40 for connections over IPv6.
indvdum@0
    65
            # Use internal directive to prohibit access on older versions.
indvdum@0
    66
            internal;
indvdum@0
    67
        }
indvdum@0
    68
indvdum@0
    69
        # Pass the php scripts to fastcgi server specified in upstream declaration.
indvdum@0
    70
        location ~ \.php$ {
indvdum@0
    71
            fastcgi_pass php;
indvdum@0
    72
            # Necessary for php.
indvdum@0
    73
            fastcgi_param SCRIPT_FILENAME  $document_root$fastcgi_script_name;
indvdum@0
    74
            # Unmodified fastcgi_params from nginx distribution.
indvdum@0
    75
            include fastcgi_params;
indvdum@0
    76
        }
indvdum@0
    77
indvdum@0
    78
        # Deny access to version control system directories.
indvdum@0
    79
        location ~ /\.svn|/\.git {
indvdum@0
    80
            deny all;
indvdum@0
    81
            internal;
indvdum@0
    82
        }
indvdum@0
    83
    }
indvdum@0
    84
indvdum@0
    85
    # If running php as fastcgi, specify php upstream.
indvdum@0
    86
    upstream php {
indvdum@0
    87
        server unix:/tmp/php.sock;
indvdum@0
    88
    }
indvdum@0
    89
}