Advertisement
funcelot

default <server-name>

Jan 29th, 2020
356
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 6.76 KB | None | 0 0
  1. server {
  2.         listen 80 default_server;
  3.         listen [::]:80 default_server;
  4.  
  5.         # SSL configuration
  6.         #
  7.         # listen 443 ssl default_server;
  8.         # listen [::]:443 ssl default_server;
  9.         #
  10.         # Note: You should disable gzip for SSL traffic.
  11.         # See: https://bugs.debian.org/773332
  12.         #
  13.         # Read up on ssl_ciphers to ensure a secure configuration.
  14.         # See: https://bugs.debian.org/765782
  15.         #
  16.         # Self signed certs generated by the ssl-cert package
  17.         # Don't use them in a production server!
  18.         #
  19.         # include snippets/snakeoil.conf;
  20.  
  21.         root /var/www/html;
  22.  
  23.         # Add index.php to the list if you are using PHP
  24.         index index.html index.htm index.nginx-debian.html;
  25.  
  26.         server_name _;
  27.  
  28.         location / {
  29.                 # First attempt to serve request as file, then
  30.                 # as directory, then fall back to displaying a 404.
  31.                 try_files $uri $uri/ =404;
  32.         }
  33.  
  34.         # pass PHP scripts to FastCGI server
  35.         #
  36.         #location ~ \.php$ {
  37.         #       include snippets/fastcgi-php.conf;
  38.         #
  39.         #       # With php-fpm (or other unix sockets):
  40.         #       fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
  41.         #       # With php-cgi (or other tcp sockets):
  42.         #       fastcgi_pass 127.0.0.1:9000;
  43.         #}
  44.  
  45.         # deny access to .htaccess files, if Apache's document root
  46.         # concurs with nginx's one
  47.         #
  48.         #location ~ /\.ht {
  49.         #       deny all;
  50.         #}
  51.  
  52.     listen [::]:443 ssl; # managed by Certbot
  53.     listen 443 ssl; # managed by Certbot
  54.     ssl_certificate /etc/letsencrypt/live/<server-name>.ru/fullchain.pem; # managed by Certbot
  55.     ssl_certificate_key /etc/letsencrypt/live/<server-name>.ru/privkey.pem; # managed by Certbot
  56.     include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
  57.     ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
  58.  
  59. }
  60.  
  61.  
  62. # Virtual Host configuration for example.com
  63. #
  64. # You can move that to a different file under sites-available/ and symlink that
  65. # to sites-enabled/ to enable it.
  66. #
  67. #server {
  68. #       listen 80;
  69. #       listen [::]:80;
  70. #
  71. #       server_name example.com;
  72. #
  73. #       root /var/www/example.com;
  74. #       index index.html;
  75. #
  76. #       location / {
  77. #               try_files $uri $uri/ =404;
  78. #       }
  79. #}
  80.  
  81. server {
  82.  
  83.         # SSL configuration
  84.         #
  85.         # listen 443 ssl default_server;
  86.         # listen [::]:443 ssl default_server;
  87.         #
  88.         # Note: You should disable gzip for SSL traffic.
  89.         # See: https://bugs.debian.org/773332
  90.         #
  91.         # Read up on ssl_ciphers to ensure a secure configuration.
  92.         # See: https://bugs.debian.org/765782
  93.         #
  94.         # Self signed certs generated by the ssl-cert package
  95.         # Don't use them in a production server!
  96.         #
  97.         # include snippets/snakeoil.conf;
  98.  
  99.         root /var/www/html;
  100.  
  101.         # Add index.php to the list if you are using PHP
  102.         index index.html index.htm index.nginx-debian.html;
  103.         server_name www.<server-name>.ru <server-name>.ru; # managed by Certbot
  104.  
  105.         location / {
  106.                 # First attempt to serve request as file, then
  107.                 # as directory, then fall back to displaying a 404.
  108.                 try_files $uri $uri/ =404;
  109.         }
  110.  
  111.         # pass PHP scripts to FastCGI server
  112.         #
  113.         #location ~ \.php$ {
  114.         #       include snippets/fastcgi-php.conf;
  115.         #
  116.         #       # With php-fpm (or other unix sockets):
  117.         #       fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
  118.         #       # With php-cgi (or other tcp sockets):
  119.         #       fastcgi_pass 127.0.0.1:9000;
  120.         #}
  121.  
  122.         # deny access to .htaccess files, if Apache's document root
  123.         # concurs with nginx's one
  124.         #
  125.         #location ~ /\.ht {
  126.         #       deny all;
  127.         #}
  128.  
  129.  
  130.     listen [::]:443 ssl ipv6only=on; # managed by Certbot
  131.     listen 443 ssl; # managed by Certbot
  132.     ssl_certificate /etc/letsencrypt/live/www.<server-name>.ru/fullchain.pem; # managed by Certbot
  133.     ssl_certificate_key /etc/letsencrypt/live/www.<server-name>.ru/privkey.pem; # managed by Certbot
  134.     include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
  135.     ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
  136. }
  137.  
  138. server {
  139.     if ($host = <server-name>.ru) {
  140.         return 301 https://$host$request_uri;
  141.     } # managed by Certbot
  142.  
  143.     if ($host = www.<server-name>.ru) {
  144.         return 301 https://$host$request_uri;
  145.     } # managed by Certbot
  146.  
  147.     listen 80 ;
  148.     listen [::]:80 ;
  149.     server_name www.<server-name>.ru <server-name>.ru;
  150.     return 404; # managed by Certbot
  151. }
  152.  
  153. server {
  154.         listen 80 ;
  155.         listen [::]:80 ;
  156.  
  157.         # SSL configuration
  158.         #
  159.         # listen 443 ssl default_server;
  160.         # listen [::]:443 ssl default_server;
  161.         #
  162.         # Note: You should disable gzip for SSL traffic.
  163.         # See: https://bugs.debian.org/773332
  164.         #
  165.         # Read up on ssl_ciphers to ensure a secure configuration.
  166.         # See: https://bugs.debian.org/765782
  167.         #
  168.         # Self signed certs generated by the ssl-cert package
  169.         # Don't use them in a production server!
  170.         #
  171.         # include snippets/snakeoil.conf;
  172.  
  173.         root /var/www/html;
  174.  
  175.         # Add index.php to the list if you are using PHP
  176.         index index.html index.htm index.nginx-debian.html;
  177.     server_name *.<server-name>.ru; # managed by Certbot
  178.  
  179.  
  180.         location / {
  181.                 # First attempt to serve request as file, then
  182.                 # as directory, then fall back to displaying a 404.
  183.                 try_files $uri $uri/ =404;
  184.         }
  185.  
  186.         # pass PHP scripts to FastCGI server
  187.         #
  188.         #location ~ \.php$ {
  189.         #       include snippets/fastcgi-php.conf;
  190.         #
  191.         #       # With php-fpm (or other unix sockets):
  192.         #       fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
  193.         #       # With php-cgi (or other tcp sockets):
  194.         #       fastcgi_pass 127.0.0.1:9000;
  195.         #}
  196.  
  197.         # deny access to .htaccess files, if Apache's document root
  198.         # concurs with nginx's one
  199.         #
  200.         #location ~ /\.ht {
  201.         #       deny all;
  202.         #}
  203.  
  204.     listen [::]:443 ssl; # managed by Certbot
  205.     listen 443 ssl; # managed by Certbot
  206.     ssl_certificate /etc/letsencrypt/live/<server-name>.ru/fullchain.pem; # managed by Certbot
  207.     ssl_certificate_key /etc/letsencrypt/live/<server-name>.ru/privkey.pem; # managed by Certbot
  208.     include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
  209.     ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
  210.  
  211.  
  212.  
  213. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement