electrotwelve

certbot nginx

Oct 14th, 2020
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 14.43 KB | None | 0 0
  1. nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
  2. nginx: configuration file /etc/nginx/nginx.conf test is successful
  3. # configuration file /etc/nginx/nginx.conf:
  4. user www-data;
  5. worker_processes auto;
  6. pid /run/nginx.pid;
  7. include /etc/nginx/modules-enabled/*.conf;
  8.  
  9. events {
  10.     worker_connections 768;
  11.     # multi_accept on;
  12. }
  13.  
  14. http {
  15.  
  16.     server_names_hash_bucket_size 64;
  17.  
  18.     ##
  19.     # Basic Settings
  20.     ##
  21.  
  22.     sendfile on;
  23.     tcp_nopush on;
  24.     tcp_nodelay on;
  25.     keepalive_timeout 65;
  26.     types_hash_max_size 2048;
  27.     # server_tokens off;
  28.  
  29.     # server_names_hash_bucket_size 64;
  30.     # server_name_in_redirect off;
  31.  
  32.     include /etc/nginx/mime.types;
  33.     default_type application/octet-stream;
  34.  
  35.     ##
  36.     # SSL Settings
  37.     ##
  38.  
  39.     ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
  40.     ssl_prefer_server_ciphers on;
  41.  
  42.     ##
  43.     # Logging Settings
  44.     ##
  45.  
  46.     access_log /var/log/nginx/access.log;
  47.     error_log /var/log/nginx/error.log;
  48.  
  49.     ##
  50.     # Gzip Settings
  51.     ##
  52.  
  53.     gzip on;
  54.  
  55.     # gzip_vary on;
  56.     # gzip_proxied any;
  57.     # gzip_comp_level 6;
  58.     # gzip_buffers 16 8k;
  59.     # gzip_http_version 1.1;
  60.     # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
  61.  
  62.     ##
  63.     # Virtual Host Configs
  64.     ##
  65.  
  66.     include /etc/nginx/conf.d/*.conf;
  67.     include /etc/nginx/sites-enabled/*;
  68. }
  69.  
  70.  
  71. #mail {
  72. #   # See sample authentication script at:
  73. #   # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
  74. #
  75. #   # auth_http localhost/auth.php;
  76. #   # pop3_capabilities "TOP" "USER";
  77. #   # imap_capabilities "IMAP4rev1" "UIDPLUS";
  78. #
  79. #   server {
  80. #       listen     localhost:110;
  81. #       protocol   pop3;
  82. #       proxy      on;
  83. #   }
  84. #
  85. #   server {
  86. #       listen     localhost:143;
  87. #       protocol   imap;
  88. #       proxy      on;
  89. #   }
  90. #}
  91.  
  92. # configuration file /etc/nginx/modules-enabled/50-mod-http-image-filter.conf:
  93. load_module modules/ngx_http_image_filter_module.so;
  94.  
  95. # configuration file /etc/nginx/modules-enabled/50-mod-http-xslt-filter.conf:
  96. load_module modules/ngx_http_xslt_filter_module.so;
  97.  
  98. # configuration file /etc/nginx/modules-enabled/50-mod-mail.conf:
  99. load_module modules/ngx_mail_module.so;
  100.  
  101. # configuration file /etc/nginx/modules-enabled/50-mod-stream.conf:
  102. load_module modules/ngx_stream_module.so;
  103.  
  104. # configuration file /etc/nginx/mime.types:
  105.  
  106. types {
  107.     text/html                             html htm shtml;
  108.     text/css                              css;
  109.     text/xml                              xml;
  110.     image/gif                             gif;
  111.     image/jpeg                            jpeg jpg;
  112.     application/javascript                js;
  113.     application/atom+xml                  atom;
  114.     application/rss+xml                   rss;
  115.  
  116.     text/mathml                           mml;
  117.     text/plain                            txt;
  118.     text/vnd.sun.j2me.app-descriptor      jad;
  119.     text/vnd.wap.wml                      wml;
  120.     text/x-component                      htc;
  121.  
  122.     image/png                             png;
  123.     image/tiff                            tif tiff;
  124.     image/vnd.wap.wbmp                    wbmp;
  125.     image/x-icon                          ico;
  126.     image/x-jng                           jng;
  127.     image/x-ms-bmp                        bmp;
  128.     image/svg+xml                         svg svgz;
  129.     image/webp                            webp;
  130.  
  131.     application/font-woff                 woff;
  132.     application/java-archive              jar war ear;
  133.     application/json                      json;
  134.     application/mac-binhex40              hqx;
  135.     application/msword                    doc;
  136.     application/pdf                       pdf;
  137.     application/postscript                ps eps ai;
  138.     application/rtf                       rtf;
  139.     application/vnd.apple.mpegurl         m3u8;
  140.     application/vnd.ms-excel              xls;
  141.     application/vnd.ms-fontobject         eot;
  142.     application/vnd.ms-powerpoint         ppt;
  143.     application/vnd.wap.wmlc              wmlc;
  144.     application/vnd.google-earth.kml+xml  kml;
  145.     application/vnd.google-earth.kmz      kmz;
  146.     application/x-7z-compressed           7z;
  147.     application/x-cocoa                   cco;
  148.     application/x-java-archive-diff       jardiff;
  149.     application/x-java-jnlp-file          jnlp;
  150.     application/x-makeself                run;
  151.     application/x-perl                    pl pm;
  152.     application/x-pilot                   prc pdb;
  153.     application/x-rar-compressed          rar;
  154.     application/x-redhat-package-manager  rpm;
  155.     application/x-sea                     sea;
  156.     application/x-shockwave-flash         swf;
  157.     application/x-stuffit                 sit;
  158.     application/x-tcl                     tcl tk;
  159.     application/x-x509-ca-cert            der pem crt;
  160.     application/x-xpinstall               xpi;
  161.     application/xhtml+xml                 xhtml;
  162.     application/xspf+xml                  xspf;
  163.     application/zip                       zip;
  164.  
  165.     application/octet-stream              bin exe dll;
  166.     application/octet-stream              deb;
  167.     application/octet-stream              dmg;
  168.     application/octet-stream              iso img;
  169.     application/octet-stream              msi msp msm;
  170.  
  171.     application/vnd.openxmlformats-officedocument.wordprocessingml.document    docx;
  172.     application/vnd.openxmlformats-officedocument.spreadsheetml.sheet          xlsx;
  173.     application/vnd.openxmlformats-officedocument.presentationml.presentation  pptx;
  174.  
  175.     audio/midi                            mid midi kar;
  176.     audio/mpeg                            mp3;
  177.     audio/ogg                             ogg;
  178.     audio/x-m4a                           m4a;
  179.     audio/x-realaudio                     ra;
  180.  
  181.     video/3gpp                            3gpp 3gp;
  182.     video/mp2t                            ts;
  183.     video/mp4                             mp4;
  184.     video/mpeg                            mpeg mpg;
  185.     video/quicktime                       mov;
  186.     video/webm                            webm;
  187.     video/x-flv                           flv;
  188.     video/x-m4v                           m4v;
  189.     video/x-mng                           mng;
  190.     video/x-ms-asf                        asx asf;
  191.     video/x-ms-wmv                        wmv;
  192.     video/x-msvideo                       avi;
  193. }
  194.  
  195. # configuration file /etc/nginx/sites-enabled/default:
  196. ##
  197. # You should look at the following URL's in order to grasp a solid understanding
  198. # of Nginx configuration files in order to fully unleash the power of Nginx.
  199. # https://www.nginx.com/resources/wiki/start/
  200. # https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/
  201. # https://wiki.debian.org/Nginx/DirectoryStructure
  202. #
  203. # In most cases, administrators will remove this file from sites-enabled/ and
  204. # leave it as reference inside of sites-available where it will continue to be
  205. # updated by the nginx packaging team.
  206. #
  207. # This file will automatically load configuration files provided by other
  208. # applications, such as Drupal or Wordpress. These applications will be made
  209. # available underneath a path with that package name, such as /drupal8.
  210. #
  211. # Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
  212. ##
  213.  
  214. # Default server configuration
  215. #
  216. server {
  217.     listen 80 default_server;
  218.     listen [::]:80 default_server;
  219.  
  220.     # SSL configuration
  221.     #
  222.     # listen 443 ssl default_server;
  223.     # listen [::]:443 ssl default_server;
  224.     #
  225.     # Note: You should disable gzip for SSL traffic.
  226.     # See: https://bugs.debian.org/773332
  227.     #
  228.     # Read up on ssl_ciphers to ensure a secure configuration.
  229.     # See: https://bugs.debian.org/765782
  230.     #
  231.     # Self signed certs generated by the ssl-cert package
  232.     # Don't use them in a production server!
  233.     #
  234.     # include snippets/snakeoil.conf;
  235.  
  236.     root /var/www/html;
  237.  
  238.     # Add index.php to the list if you are using PHP
  239.     index index.php index.html index.htm index.nginx-debian.html;
  240.  
  241.     server_name _;
  242.  
  243.     location / {
  244.         # First attempt to serve request as file, then
  245.         # as directory, then fall back to displaying a 404.
  246.         try_files $uri $uri/ =404;
  247.     }
  248.  
  249.     # pass PHP scripts to FastCGI server
  250.     #
  251.     location ~ \.php$ {
  252.         include snippets/fastcgi-php.conf;
  253.     #
  254.     #   # With php-fpm (or other unix sockets):
  255.         fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
  256.     #   # With php-cgi (or other tcp sockets):
  257.     #   fastcgi_pass 127.0.0.1:9000;
  258.     }
  259.  
  260.     # deny access to .htaccess files, if Apache's document root
  261.     # concurs with nginx's one
  262.     #
  263.     location ~ /\.ht {
  264.         deny all;
  265.     }
  266. }
  267.  
  268.  
  269.  
  270. server {
  271.  
  272.     # SSL configuration
  273.     #
  274.     # listen 443 ssl default_server;
  275.     # listen [::]:443 ssl default_server;
  276.     #
  277.     # Note: You should disable gzip for SSL traffic.
  278.     # See: https://bugs.debian.org/773332
  279.     #
  280.     # Read up on ssl_ciphers to ensure a secure configuration.
  281.     # See: https://bugs.debian.org/765782
  282.     #
  283.     # Self signed certs generated by the ssl-cert package
  284.     # Don't use them in a production server!
  285.     #
  286.     # include snippets/snakeoil.conf;
  287.  
  288.     root /var/www/html;
  289.  
  290.     # Add index.php to the list if you are using PHP
  291.     index index.php index.html index.htm index.nginx-debian.html;
  292.     server_name phpmyadmin.hrishib.com; # managed by Certbot
  293.  
  294.  
  295.     location / {
  296.         # First attempt to serve request as file, then
  297.         # as directory, then fall back to displaying a 404.
  298.         try_files $uri $uri/ =404;
  299.     }
  300.  
  301.     # pass PHP scripts to FastCGI server
  302.     #
  303.     location ~ \.php$ {
  304.         include snippets/fastcgi-php.conf;
  305.     #
  306.     #   # With php-fpm (or other unix sockets):
  307.         fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
  308.     #   # With php-cgi (or other tcp sockets):
  309.     #   fastcgi_pass 127.0.0.1:9000;
  310.     }
  311.  
  312.     # deny access to .htaccess files, if Apache's document root
  313.     # concurs with nginx's one
  314.     #
  315.     location ~ /\.ht {
  316.         deny all;
  317.     }
  318.  
  319.  
  320.     listen [::]:443 ssl ipv6only=on; # managed by Certbot
  321.     listen 443 ssl; # managed by Certbot
  322.     ssl_certificate /etc/letsencrypt/live/phpmyadmin.hrishib.com/fullchain.pem; # managed by Certbot
  323.     ssl_certificate_key /etc/letsencrypt/live/phpmyadmin.hrishib.com/privkey.pem; # managed by Certbot
  324.     include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
  325.     ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
  326.  
  327. }
  328. server {
  329.     if ($host = phpmyadmin.hrishib.com) {
  330.         return 301 https://$host$request_uri;
  331.     } # managed by Certbot
  332.  
  333.  
  334.     listen 80 ;
  335.     listen [::]:80 ;
  336.     server_name phpmyadmin.hrishib.com;
  337.     return 404; # managed by Certbot
  338.  
  339.  
  340. }
  341. # configuration file /etc/nginx/snippets/fastcgi-php.conf:
  342. # regex to split $uri to $fastcgi_script_name and $fastcgi_path
  343. fastcgi_split_path_info ^(.+?\.php)(/.*)$;
  344.  
  345. # Check that the PHP script exists before passing it
  346. try_files $fastcgi_script_name =404;
  347.  
  348. # Bypass the fact that try_files resets $fastcgi_path_info
  349. # see: http://trac.nginx.org/nginx/ticket/321
  350. set $path_info $fastcgi_path_info;
  351. fastcgi_param PATH_INFO $path_info;
  352.  
  353. fastcgi_index index.php;
  354. include fastcgi.conf;
  355.  
  356. # configuration file /etc/nginx/fastcgi.conf:
  357.  
  358. fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
  359. fastcgi_param  QUERY_STRING       $query_string;
  360. fastcgi_param  REQUEST_METHOD     $request_method;
  361. fastcgi_param  CONTENT_TYPE       $content_type;
  362. fastcgi_param  CONTENT_LENGTH     $content_length;
  363.  
  364. fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
  365. fastcgi_param  REQUEST_URI        $request_uri;
  366. fastcgi_param  DOCUMENT_URI       $document_uri;
  367. fastcgi_param  DOCUMENT_ROOT      $document_root;
  368. fastcgi_param  SERVER_PROTOCOL    $server_protocol;
  369. fastcgi_param  REQUEST_SCHEME     $scheme;
  370. fastcgi_param  HTTPS              $https if_not_empty;
  371.  
  372. fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
  373. fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;
  374.  
  375. fastcgi_param  REMOTE_ADDR        $remote_addr;
  376. fastcgi_param  REMOTE_PORT        $remote_port;
  377. fastcgi_param  SERVER_ADDR        $server_addr;
  378. fastcgi_param  SERVER_PORT        $server_port;
  379. fastcgi_param  SERVER_NAME        $server_name;
  380.  
  381. # PHP only, required if PHP was built with --enable-force-cgi-redirect
  382. fastcgi_param  REDIRECT_STATUS    200;
  383.  
  384. # configuration file /etc/letsencrypt/options-ssl-nginx.conf:
  385. # This file contains important security parameters. If you modify this file
  386. # manually, Certbot will be unable to automatically provide future security
  387. # updates. Instead, Certbot will print and log an error message with a path to
  388. # the up-to-date file that you will need to refer to when manually updating
  389. # this file.
  390.  
  391. ssl_session_cache shared:le_nginx_SSL:10m;
  392. ssl_session_timeout 1440m;
  393. ssl_session_tickets off;
  394.  
  395. ssl_protocols TLSv1.2 TLSv1.3;
  396. ssl_prefer_server_ciphers off;
  397.  
  398. ssl_ciphers "ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384";
  399.  
  400. # configuration file /etc/nginx/sites-enabled/hrishib.com:
  401. server {
  402.     server_name hrishib.com www.hrishib.com;
  403.     root /var/www/hrishib.com;
  404.  
  405.     index index.php index.htm index.html;
  406.  
  407.     location / {
  408.         try_files $uri $uri/ =404;
  409.     }
  410.  
  411.     location ~ \.php$ {
  412.         include snippets/fastcgi-php.conf;
  413.         fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
  414.      }
  415.  
  416.     location ~ /\.ht {
  417.         deny all;
  418.     }
  419.  
  420.  
  421.     listen 443 ssl; # managed by Certbot
  422.     ssl_certificate /etc/letsencrypt/live/hrishib.com/fullchain.pem; # managed by Certbot
  423.     ssl_certificate_key /etc/letsencrypt/live/hrishib.com/privkey.pem; # managed by Certbot
  424.     include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
  425.     ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
  426.  
  427.  
  428. }
  429.  
  430. server {
  431.     if ($host = www.hrishib.com) {
  432.         return 301 https://$host$request_uri;
  433.     } # managed by Certbot
  434.  
  435.  
  436.     if ($host = hrishib.com) {
  437.         return 301 https://$host$request_uri;
  438.     } # managed by Certbot
  439.  
  440.  
  441.     listen 80;
  442.     server_name hrishib.com www.hrishib.com;
  443.     return 404; # managed by Certbot
  444.  
  445.  
  446.  
  447.  
  448. }
  449.  
  450. # configuration file /etc/nginx/sites-enabled/phpmyadmin.hrishib.com:
  451. server {
  452.   server_name phpmadmin.hrishib.com;
  453.   root /usr/share/phpmyadmin;
  454.   index index.php index.html index.htm index.nginx-debian.html;
  455.  
  456.   access_log /var/log/nginx/phpmyadmin_access.log;
  457.   error_log /var/log/nginx/phpmyadmin_error.log;
  458.  
  459.   location / {
  460.     try_files $uri $uri/ /index.php;
  461.   }
  462.  
  463.   location ~ ^/(doc|sql|setup)/ {
  464.     deny all;
  465.   }
  466.  
  467.   location ~ \.php$ {
  468.     include snippets/fastcgi-php.conf;
  469.     fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
  470.   }
  471.  
  472.   location ~ /\.ht {
  473.     deny all;
  474.   }
  475. }
Add Comment
Please, Sign In to add comment