mahmudkuet

Sample Nginx server configuration

Aug 9th, 2018
144
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ##
  2. # You should look at the following URL's in order to grasp a solid understanding
  3. # of Nginx configuration files in order to fully unleash the power of Nginx.
  4. # http://wiki.nginx.org/Pitfalls
  5. # http://wiki.nginx.org/QuickStart
  6. # http://wiki.nginx.org/Configuration
  7. #
  8. # Generally, you will want to move this file somewhere, and start with a clean
  9. # file but keep this around for reference. Or just disable in sites-enabled.
  10. #
  11. # Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
  12. ##
  13.  
  14. # Default server configuration
  15. #
  16.  
  17.  
  18. server {
  19.  
  20.     # SSL configuration
  21.     #
  22.     # listen 443 ssl default_server;
  23.     # listen [::]:443 ssl default_server;
  24.     #
  25.     # Note: You should disable gzip for SSL traffic.
  26.     # See: https://bugs.debian.org/773332
  27.     #
  28.     # Read up on ssl_ciphers to ensure a secure configuration.
  29.     # See: https://bugs.debian.org/765782
  30.     #
  31.     # Self signed certs generated by the ssl-cert package
  32.     # Don't use them in a production server!
  33.     #
  34.     # include snippets/snakeoil.conf;
  35.  
  36.     root /var/www/www.vinndo.com/html/public;
  37.  
  38.     # Add index.php to the list if you are using PHP
  39.     index index.php index.html index.htm index.nginx-debian.html;
  40.  
  41.     server_name vinndo.com www.vinndo.com vadmin.vinndo.com developer.vinndo.com;
  42.  
  43.     location / {
  44.         # First attempt to serve request as file, then
  45.         # as directory, then fall back to displaying a 404.
  46.         try_files $uri $uri/ /index.php?$query_string;
  47.     }
  48.  
  49.     # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  50.     #
  51.     location ~ \.php$ {
  52.         include snippets/fastcgi-php.conf;
  53.     #
  54.     #   # With php7.0-cgi alone:
  55.     #   fastcgi_pass 127.0.0.1:9000;
  56.     #   # With php7.0-fpm:
  57.         fastcgi_pass unix:/run/php/php7.2-fpm.sock;
  58.     }
  59.    
  60.     #browser caching of static assets
  61.          location ~*  \.(jpg|jpeg|png|gif|ico|css|js|svg)$ {
  62.                 expires 7d;
  63.         }
  64.    
  65.     # deny access to .htaccess files, if Apache's document root
  66.     # concurs with nginx's one
  67.     #
  68.     #location ~ /\.ht {
  69.     #   deny all;
  70.     #}
  71.    
  72.     listen [::]:443 ssl; # managed by Certbot
  73.         listen 443 ssl; # managed by Certbot
  74.  
  75.         if ($scheme = http) {
  76.             return 301 https://$server_name$request_uri;
  77.     }
  78.     if ($host ~* ^www\.(.*)$) {
  79.         return 301 https://vinndo.com$request_uri;
  80.     }
  81.     ssl_certificate /etc/letsencrypt/live/developer.vinndo.com/fullchain.pem; # managed by Certbot
  82.     ssl_certificate_key /etc/letsencrypt/live/developer.vinndo.com/privkey.pem; # managed by Certbot
  83.         include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
  84.         ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
  85.  
  86.  
  87.  
  88.  
  89.  
  90. }
  91.  
  92. # Virtual Host configuration for example.com
  93. #
  94. # You can move that to a different file under sites-available/ and symlink that
  95. # to sites-enabled/ to enable it.
  96. #
  97. #server {
  98. #   listen 80;
  99. #   listen [::]:80;
  100. #
  101. #   server_name example.com;
  102. #
  103. #   root /var/www/example.com;
  104. #   index index.html;
  105. #
  106. #   location / {
  107. #       try_files $uri $uri/ =404;
  108. #   }
  109. #}
  110.  
  111. server {
  112.     if ($host = www.vinndo.com) {
  113.         return 301 https://$host$request_uri;
  114.     } # managed by Certbot
  115.  
  116.  
  117.     if ($host = vadmin.vinndo.com) {
  118.         return 301 https://$host$request_uri;
  119.     } # managed by Certbot
  120.  
  121.  
  122.     if ($host = developer.vinndo.com) {
  123.         return 301 https://$host$request_uri;
  124.     } # managed by Certbot
  125.  
  126.     if ($host = vinndo.com) {
  127.         return 301 https://$host$request_uri;
  128.     } # managed by Certbot
  129.  
  130.     listen 80;
  131.     listen [::]:80;
  132.  
  133.  
  134.     server_name vinndo.com www.vinndo.com vadmin.vinndo.com developer.vinndo.com;
  135.     return 404; # managed by Certbot
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142. }
  143.  
  144.  
  145.  
  146. server {
  147.     if ($host = vinndo.com) {
  148.         return 301 https://$host$request_uri;
  149.     } # managed by Certbot
  150.  
  151.  
  152.  
  153.     server_name vinndo.com www.vinndo.com vadmin.vinndo.com developer.vinndo.com;
  154.  
  155.     listen 80;
  156.     listen [::]:80;
  157.     return 404; # managed by Certbot
  158.  
  159.  
  160. }
RAW Paste Data