Advertisement
imranmodel32

Nginx config

Sep 1st, 2015
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Nginx 4.36 KB | None | 0 0
  1. # You may add here your
  2. # server {
  3. #   ...
  4. # }
  5. # statements for each of your virtual hosts to this file
  6.  
  7. ##
  8. # You should look at the following URL's in order to grasp a solid understanding
  9. # of Nginx configuration files in order to fully unleash the power of Nginx.
  10. # http://wiki.nginx.org/Pitfalls
  11. # http://wiki.nginx.org/QuickStart
  12. # http://wiki.nginx.org/Configuration
  13. #
  14. # Generally, you will want to move this file somewhere, and start with a clean
  15. # file but keep this around for reference. Or just disable in sites-enabled.
  16. #
  17. # Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
  18. ##
  19.  
  20. server {
  21.     listen 80;
  22.     server_name wpbean.com www.wpbean.com;
  23.     return 301 https://wpbean.com$request_uri;
  24. }
  25.  
  26. server {
  27.     listen 443 ssl;
  28.     server_name wpbean.com;
  29.     ssl_certificate /etc/nginx/ssl/wpbean.crt;
  30.     ssl_certificate_key /etc/nginx/ssl/wpbean.key;
  31.     ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  32.     ssl_prefer_server_ciphers on;
  33.     ssl_ciphers AES256+EECDH:AES256+EDH:!aNULL;
  34.  
  35.     rewrite ^/sitemap_index\.xml$ /index.php?sitemap=1 last;
  36.     rewrite ^/([^/]+?)-sitemap([0-9]+)?\.xml$ /index.php?sitemap=$1&sitemap_n=$2 last;
  37.  
  38.     index index.php;
  39.     root /usr/share/nginx/html;
  40.     location / {
  41.         try_files $uri $uri/ /index.php?$args;
  42.     }
  43.  
  44.     error_page 404 /404.html;
  45.     error_page 500 502 503 504 /50x.html;
  46.     location = /50x.html {
  47.         root /usr/share/nginx/html;
  48.     }
  49.  
  50.     location ~ \.php$ {
  51.         try_files $uri =404;
  52.         fastcgi_split_path_info ^(.+\.php)(/.+)$;
  53.         fastcgi_pass unix:/var/run/php5-fpm.sock;
  54.         fastcgi_index index.php;
  55.         include fastcgi_params;
  56.     }
  57.  
  58.     location ~ ^/wp-content/uploads/edd/(.*?)\.zip$ {
  59.         rewrite / permanent;
  60.     }
  61. }
  62.  
  63. server {
  64.     listen 80 default_server;
  65.     listen [::]:80 default_server ipv6only=on;
  66.    
  67.     root /usr/share/nginx/html;
  68.     index index.php index.html index.htm;
  69.  
  70.     # Make site accessible from http://localhost/
  71.     server_name localhost;
  72.    
  73.     rewrite ^/sitemap_index\.xml$ /index.php?sitemap=1 last;
  74.     rewrite ^/([^/]+?)-sitemap([0-9]+)?\.xml$ /index.php?sitemap=$1&sitemap_n=$2 last;
  75.  
  76.  
  77.     location / {
  78.         # First attempt to serve request as file, then
  79.         # as directory, then fall back to displaying a 404.
  80.         try_files $uri $uri/ /index.php?$args;
  81.         # Uncomment to enable naxsi on this location
  82.         # include /etc/nginx/naxsi.rules
  83.     }
  84.  
  85.     error_page 404 /404.html;
  86.     error_page 500 502 503 504 /50x.html;
  87.     location = /50x.html {
  88.         root /usr/share/nginx/html;
  89.     }
  90.  
  91.     location ~ \.php$ {
  92.         try_files $uri =404;
  93.         fastcgi_split_path_info ^(.+\.php)(/.+)$;
  94.         fastcgi_pass unix:/var/run/php5-fpm.sock;
  95.         fastcgi_index index.php;
  96.         include fastcgi_params;
  97.     }
  98.  
  99.     location ~ ^/wp-content/uploads/edd/(.*?)\.zip$ {
  100.         rewrite / permanent;
  101.     }
  102.  
  103.     # Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests
  104.     #location /RequestDenied {
  105.     #   proxy_pass http://127.0.0.1:8080;    
  106.     #}
  107.  
  108.     #error_page 404 /404.html;
  109.  
  110.     # redirect server error pages to the static page /50x.html
  111.     #
  112.     #error_page 500 502 503 504 /50x.html;
  113.     #location = /50x.html {
  114.     #   root /usr/share/nginx/html;
  115.     #}
  116.  
  117.     # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  118.     #
  119.     location ~ \.php$ {
  120.         fastcgi_split_path_info ^(.+\.php)(/.+)$;
  121.     #   # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
  122.     #
  123.     #   # With php5-cgi alone:
  124.     #   fastcgi_pass 127.0.0.1:9000;
  125.     #   # With php5-fpm:
  126.         fastcgi_pass unix:/var/run/php5-fpm.sock;
  127.         fastcgi_index index.php;
  128.         include fastcgi_params;
  129.     }
  130.  
  131.     # deny access to .htaccess files, if Apache's document root
  132.     # concurs with nginx's one
  133.     #
  134.     #location ~ /\.ht {
  135.     #   deny all;
  136.     #}
  137. }
  138.  
  139.  
  140. # another virtual host using mix of IP-, name-, and port-based configuration
  141. #
  142. #server {
  143. #   listen 8000;
  144. #   listen somename:8080;
  145. #   server_name somename alias another.alias;
  146. #   root html;
  147. #   index index.html index.htm;
  148. #
  149. #   location / {
  150. #       try_files try_files $uri $uri/ =404;
  151. #   }
  152. #}
  153.  
  154.  
  155. # HTTPS server
  156. #
  157. #server {
  158. #   listen 443;
  159. #   server_name localhost;
  160. #
  161. #   root html;
  162. #   index index.html index.htm;
  163. #
  164. #   ssl on;
  165. #   ssl_certificate cert.pem;
  166. #   ssl_certificate_key cert.key;
  167. #
  168. #   ssl_session_timeout 5m;
  169. #
  170. #   ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
  171. #   ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES";
  172. #   ssl_prefer_server_ciphers on;
  173. #
  174. #   location / {
  175. #       try_files $uri $uri/ =404;
  176. #   }
  177. #}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement