gacanepa

Nginx Virtual Host sample (with SSL)

Dec 17th, 2015
1,211
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. include /etc/nginx/blockuseragents.rules;
  2. limit_conn_zone $binary_remote_addr zone=addr:5m;
  3. server {
  4.     if ($blockedagent) {
  5.        return 403;
  6.     }  
  7.     if ($request_method !~ ^(GET|HEAD|POST)$) {
  8.     return 444;
  9.     }
  10.     limit_conn addr 1;  
  11.     listen       192.168.0.25:80 default_server;  
  12.     server_tokens   off;
  13.     server_name  tecmintlovesnginx.com www.tecmintlovesnginx.com;
  14.     return 301 https://$server_name$request_uri;
  15.     access_log  /var/www/logs/tecmintlovesnginx.access.log;  
  16.     error_log  /var/www/logs/tecmintlovesnginx.error.log error;
  17.     root   /var/www/tecmintlovesnginx.com/public_html;  
  18.     index  index.html index.htm;
  19.     location /img/ {
  20.     valid_referers none blocked 192.168.0.25;
  21.     if ($invalid_referer) {
  22.             return   403;
  23.         }
  24.     }
  25. }
  26. server {
  27.     listen 192.168.0.25:443 ssl;
  28.     server_tokens   off;
  29.     server_name  tecmintlovesnginx.com www.tecmintlovesnginx.com;
  30.     root   /var/www/tecmintlovesnginx.com/public_html;  
  31.     ssl_certificate /etc/nginx/sites-enabled/certs/tecmintlovesnginx.crt;
  32.     ssl_certificate_key /etc/nginx/sites-enabled/certs/tecmintlovesnginx.key;
  33.     ssl_protocols       TLSv1 TLSv1.1 TLSv1.2; 
  34. }
  35. include /etc/nginx/conf.d/*.conf;
RAW Paste Data