5
# This file is meant to deliver a basic understanding of server blocks.
9
# You should look at the following URL's in order to grasp a solid understanding
10
# of Nginx configuration files in order to fully unleash the power of Nginx.
11
# http://wiki.nginx.org/Pitfalls
12
# http://wiki.nginx.org/Configuration
16
# Every "virtual host" that you serve will need to be in its own server block.
22
# After reading this file, you should understand the structure of server blocks
23
# and be able to understand how to modify them to your needs.
28
# The listen directive is only needed if this server block:
29
# needs to listen for IPv6
30
# needs to listen on another port
31
# If you need to listen for IPv6 then both of the following lines can
33
# DO NOT listen for both SSL and non-SSL in the same server block.
34
#listen 80; ## listen for ipv4; this line is default and implied
35
#listen [::]:80 default ipv6only=on; ## listen for ipv6
37
# root specifies the document root for the requests
38
root /usr/share/nginx/www;
40
# index specifies the list of files (in order) to be tried in the event
41
# no file is requested in the URI.
42
index index.html index.htm;
44
# Make site accessible from http://localhost/
45
server_name localhost;
47
# Unless you run everything as a proxy, you will want to have a root
48
# location block. This example controls how files are requested.
50
# First attempt to serve request as file, then as directory,
51
# then fall back to index.html. /index.html would normally be
52
# front end controller pattern for handling "clean url's" in
53
# a CMS such as Drupal or Wordpress.
54
try_files $uri $uri/ /index.html;
57
# This location block would server any requests for /doc as well
58
# as anything below it.
60
# root changes the root directory for these requests
62
# autoindex on allows these request to display directory listings
63
# if a directory was requested
65
# We'll allow these requests for localhost
67
# Anyone outside is forbidden
71
# This location block would serve any requests for /images as well
72
# as anything below it.
74
# This is the same as /doc except we don't allow indexes
81
# This will serve the file 404.html in the event the request is not found.
82
error_page 404 /404.html;
84
# redirect server error pages to the static page /50x.html
85
# This will hit if the server generates a 500, 502, 503, or 504 status code
86
error_page 500 502 503 504 /50x.html;
88
# This location block isn't actually needed because our root for the
89
# server block is the same directory. However, this could be used to
90
# have a central directory for all error html files.
91
location = /50x.html {
92
root /usr/share/nginx/www;
95
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
96
# If you're going to proxy to Apache, then just push the whole
97
# request to it. You'll generally have better performance with
98
# a dedicated php listener (fastcgi: php-cgi, php-fpm).
100
# proxy_pass http://127.0.0.1;
103
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
104
# This is used for passing to php-cgi and php-fpm.
105
# For more information see /usr/share/doc/nginx/examples/php
107
# This is where the php socket is listening.
108
fastcgi_pass 127.0.0.1:9000;
109
fastcgi_index index.php;
110
include fastcgi_params;
113
# deny access to .htaccess, .htpasswd, and .htgroup files
120
# another virtual host using mix of IP-, name-, and port-based configuration
123
listen somename:8080;
124
server_name somename alias another.alias;
126
index index.html index.htm;
129
try_files $uri $uri/ /index.html;
137
server_name localhost;
140
index index.html index.htm;
143
ssl_certificate cert.pem;
144
ssl_certificate_key cert.key;
146
ssl_session_timeout 5m;
148
ssl_protocols SSLv3 TLSv1;
149
ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP;
150
ssl_prefer_server_ciphers on;
153
try_files $uri $uri/ /index.html;