NGINX configure auto generator

The easiest way to configure a performant, secure, and stable NGINX server.

https://www.digitalocean.com/community/tools/nginx

demo

https://www.digitalocean.com/community/tools/nginx?domains.0.server.domain=xgqfrms.xyz&global.https.ocspCloudflareType=both&global.https.ocspGoogleType=both&global.https.ocspOpenDnsType=both

# Download the generated config: nginxconfig.io-xgqfrms.xyz.tar.gz
# and upload it to your server's/etc/nginx directory. # or, Copy a base64 string of the compressed config, paste it in your server's command line and execute it. $ echo 'H4sIAHNbUF8CA+0aaXPbuNWf9StQb6bZpMtbhyuNx+OxvbFn7NgTeTvb2bgciAQprEGAC4A6UmV/ex8PSaSOJO007hHD5qF3AQ94eHjAI48pn5mB4NHBVys2lF6vVzyhbD69Trt34Hg9t213Op2ud1CS28g+eIKSKY0lQgffaPkOvSGcSKxJiEZzxHNzyK2BxiYVre/QWOtU9S1rOp2aIY2pxkwEBHMwmcSCK8k41XNLC8GUVXCfhCLBlCvTNhWREyLNEnA8i3+LZKLM2fzDH2MmRpiZhXRTBCo9YyILI4YluZ+n5Hgk9Hib6I0QMfsUwW1K+DlXK4pWK4M2oM0Cyhgh1njQSmm4hUWWzHipiwn4QWsq5CORfipBc6WIKohwpsUKJRlNqPa5iCgjqNvpeJ1Bq0UmhGuF/t7K6ZOMaerjICCpruoRfFCgKiHQ7ZwEmgquliI+tlq5cpWIYIylIrrZ2ExHxlEpRxEeFg2ol2UlOkihfWmmxnuRIWF4vo0sR9HX4pFwtUJGUYllIgZW7Uci4+EWVsNIKH+M1dhP8MxX9AO0zrXbVYsDRqGLCtRIhPMS73RvoPNy9Hfo5urmonilPGBZ2FQNJTQhZlFFKS4kEYZu9nPQiginKaMBzvvVEoEm2lBaEpys6rgWMYx1XPzKx0cpH5Sq28MESwtApU1YJY0JgLJWIqWQGyybPAVNzoKmWPJV1cPhddnFivlgWAra6GtQSmQwyk442EIGOBgXqimwBRL2QUDfsZPBDinBIwHjK4eiqu6cRhElxiVhLMEcpVjihGiYIJGQ6PzyAgU0HROpMqqJW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EjrACwAAA==' | base64 --decode | tee /etc/nginx/nginxconfig.io-xgqfrms.xyz.tar.gz > /dev/null # Navigate to your NGINX configuration directory on your server:
$ cd /etc/nginx # Create a backup of your current NGINX configuration:
$ tar -czvf nginx_$(date +'%F_%H-%M-%S').tar.gz nginx.conf sites-available/ sites-enabled/ nginxconfig.io/ # Extract the new compressed configuration archive using tar:
$ tar -xzvf nginxconfig.io-xgqfrms.xyz.tar.gz

Let's Encrypt

# Generate Diffie-Hellman keys by running this command on your server:
$ openssl dhparam -out /etc/nginx/dhparam.pem 2048 # Create a common ACME-challenge directory (for Let's Encrypt):
$ mkdir -p /var/www/_letsencrypt
$ chown www-data /var/www/_letsencrypt

# Comment out SSL related directives in the configuration:
$ sed -i -r 's/(listen .*443)/\1;#/g; s/(ssl_(certificate|certificate_key|trusted_certificate) )/#;#\1/g' /etc/nginx/sites-available/xgqfrms.xyz.conf # Reload your NGINX server:
$ sudo nginx -t && sudo systemctl reload nginx # Obtain SSL certificates from Let's Encrypt using Certbot:
$ certbot certonly --webroot -d xgqfrms.xyz --email info@xgqfrms.xyz -w /var/www/_letsencrypt -n --agree-tos --force-renewal # Uncomment SSL related directives in the configuration:
$ sed -i -r 's/#?;#//g' /etc/nginx/sites-available/xgqfrms.xyz.conf # Reload your NGINX server:
$ sudo nginx -t && sudo systemctl reload nginx # Configure Certbot to reload NGINX when it successfully renews certificates:
$ echo -e '#!/bin/bash\nnginx -t && systemctl reload nginx' | sudo tee /etc/letsencrypt/renewal-hooks/post/nginx-reload.sh
$ sudo chmod a+x /etc/letsencrypt/renewal-hooks/post/nginx-reload.sh

Let's go live!

# Reload NGINX to load in your new configuration:
$ sudo nginx -t && sudo systemctl reload nginx

configs

/etc/nginx/nginx.conf

# Generated by nginxconfig.io
# https://www.digitalocean.com/community/tools/nginx?domains.0.server.domain=xgqfrms.xyz&global.https.ocspCloudflareType=both&global.https.ocspGoogleType=both&global.https.ocspOpenDnsType=both user www-data;
pid /run/nginx.pid;
worker_processes auto;
worker_rlimit_nofile 65535; events {
multi_accept on;
worker_connections 65535;
} http {
charset utf-8;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
server_tokens off;
log_not_found off;
types_hash_max_size 2048;
client_max_body_size 16M; # MIME
include mime.types;
default_type application/octet-stream; # Logging
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log warn; # SSL
ssl_session_timeout 1d;
ssl_session_cache shared:SSL:10m;
ssl_session_tickets off; # Diffie-Hellman parameter for DHE ciphersuites
ssl_dhparam /etc/nginx/dhparam.pem; # Mozilla Intermediate configuration
ssl_protocols TLSv1.2 TLSv1.3;
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; # OCSP Stapling
ssl_stapling on;
ssl_stapling_verify on;
resolver 1.1.1.1 1.0.0.1 [2606:4700:4700::1111] [2606:4700:4700::1001] 8.8.8.8 8.8.4.4 [2001:4860:4860::8888] [2001:4860:4860::8844] 208.67.222.222 208.67.220.220 [2620:119:35::35] [2620:119:53::53] valid=60s;
resolver_timeout 2s; # Load configs
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}

/etc/nginx/sites-available/xgqfrms.xyz.conf

server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name xgqfrms.xyz;
set $base /var/www/xgqfrms.xyz;
root $base/public; # SSL
ssl_certificate /etc/letsencrypt/live/xgqfrms.xyz/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/xgqfrms.xyz/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/xgqfrms.xyz/chain.pem; # security
include nginxconfig.io/security.conf; # index.php
index index.php; # index.php fallback
location / {
try_files $uri $uri/ /index.php?$query_string;
} # additional config
include nginxconfig.io/general.conf; # handle .php
location ~ \.php$ {
include nginxconfig.io/php_fastcgi.conf;
}
} # subdomains redirect
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name *.xgqfrms.xyz; # SSL
ssl_certificate /etc/letsencrypt/live/xgqfrms.xyz/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/xgqfrms.xyz/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/xgqfrms.xyz/chain.pem;
return 301 https://xgqfrms.xyz$request_uri;
} # HTTP redirect
server {
listen 80;
listen [::]:80;
server_name .xgqfrms.xyz;
include nginxconfig.io/letsencrypt.conf; location / {
return 301 https://xgqfrms.xyz$request_uri;
}
}

/etc/nginx/nginxconfig.io/letsencrypt.conf

# ACME-challenge
location ^~ /.well-known/acme-challenge/ {
root /var/www/_letsencrypt;
}

/etc/nginx/nginxconfig.io/security.conf

# security headers
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "no-referrer-when-downgrade" always;
add_header Content-Security-Policy "default-src 'self' http: https: data: blob: 'unsafe-inline'" always;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always; # . files
location ~ /\.(?!well-known) {
deny all;
}

/etc/nginx/nginxconfig.io/general.conf

# favicon.ico
location = /favicon.ico {
log_not_found off;
access_log off;
} # robots.txt
location = /robots.txt {
log_not_found off;
access_log off;
} # assets, media
location ~* \.(?:css(\.map)?|js(\.map)?|jpe?g|png|gif|ico|cur|heic|webp|tiff?|mp3|m4a|aac|ogg|midi?|wav|mp4|mov|webm|mpe?g|avi|ogv|flv|wmv)$ {
expires 7d;
access_log off;
} # svg, fonts
location ~* \.(?:svgz?|ttf|ttc|otf|eot|woff2?)$ {
add_header Access-Control-Allow-Origin "*";
expires 7d;
access_log off;
} # gzip
gzip on;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_types text/plain text/css text/xml application/json application/javascript application/rss+xml application/atom+xml image/svg+xml;

/etc/nginx/nginxconfig.io/php_fastcgi.conf

# 404
try_files $fastcgi_script_name =404; # default fastcgi_params
include fastcgi_params; # fastcgi settings
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
fastcgi_buffers 8 16k;
fastcgi_buffer_size 32k; # fastcgi params
fastcgi_param DOCUMENT_ROOT $realpath_root;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param PHP_ADMIN_VALUE "open_basedir=$base/:/usr/lib/php/:/tmp/";


refs



xgqfrms 2012-2020

www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!


NGINX configure auto generator的更多相关文章

  1. URL & QRcode auto generator

    URL & QRcode auto generator 二维码 npm & qrcode https://www.npmjs.com/package/qrcode https://ww ...

  2. Nginx Configure

    1.主配置/etc/nginx.conf #/etc/nginx/nginx.conf user nginx; worker_processes auto; error_log /var/log/ng ...

  3. gitignore auto generator

    gitignore auto generator .gitignore https://gitignore.io/ https://www.toptal.com/developers/gitignor ...

  4. Nginx Configure时配置

    Configure Arguments Configure arguments common for nginx binaries from pre-built packages for stable ...

  5. nginx configure fastdfs + SSL

    ./configure \ --prefix=/usr/local/nginx \ --with-http_stub_status_module \ --with-http_ssl_module \ ...

  6. nginx configure参数

    下面是nginx源码程序的configure参数: --prefix= 指向安装目录.默认为:/usr/local/nginx --sbin-path= 指定执行程序文件存放位置.默认为:prefix ...

  7. nginx configure 错误记录

    1.the HTTP rewrite module requires the PCRE library. ./configure: error: the HTTP rewrite module req ...

  8. 转载:configure执行流程(1.5.2)《深入理解Nginx》(陶辉)

    原文:https://book.2cto.com/201304/19619.html 我们看到configure命令支持非常多的参数,读者可能会好奇它在执行时到底做了哪些事情,本节将通过解析confi ...

  9. centos 7.0 安装nginx 1.9.10

    可以参考以前安装成功的案例 centos 7.0 nginx 1.7.9成功安装过程 官网下载 http://nginx.org/en/download.html nginx下载位置 /usr/loc ...

随机推荐

  1. IDEA SSM后端框架入门

    SSM框架 如果对SSM一无所知,推荐先去看这本书,可以在微信读书上看. 知识点 控制器返回对象时,对象需要有getter,setter方法,才能自动转化为json数据类型. 一个服务管理者对应多个业 ...

  2. (008)每日SQL学习:Oracle Not Exists 及 Not In 使用

    今天遇到一个问题,not in 查询失效,我以为是穿越了,仔细查了点资料,原来理解有误! select value from temp_a a where a.id between 1 and 100 ...

  3. 某cms最新版前台RCE漏洞(无需任何权限)2020-03-15

    漏洞文件:application/common/controller/Base.php 中的 getAddonTemplate 方法: 错误的使用了public,导致我们可以直接外部访问. 然后使用了 ...

  4. 浅谈正向代理、反向代理和CDN的区别

    一.正向代理 1.正向代理位于客户端和源服务器之间的服务器(代理服务器): 2.隐藏客户端:由代理服务器代替客户端去访问目标服务器,用户需要设置代理服务器的IP和端口: 3.每一次请求是到代理服务器, ...

  5. Cobbler 自动化部署 (转载)

    https://www.cnblogs.com/linuxliu/p/7668048.html root默认密码为 123456 (建议修改) ks文件 #platform=x86, AMD64, o ...

  6. Kubernetes -- secret (敏感数据管理)

    https://www.kubernetes.org.cn/secret secret 主要解决密码.token.密钥等敏感数据的配置问题,而不需要把这些敏感数据暴露到镜像或者Pod Spec中 Se ...

  7. Java基本类型的内存分配在栈还是堆

    我们都知道在Java里面new出来的对象都是在堆上分配空间存储的,但是针对基本类型却有所区别,基本类型可以分配在栈上,也可以分配在堆上,这是为什么? 在这之前,我们先看下Java的基本类型8种分别是: ...

  8. Best Reward && Girls' research

    After an uphill battle, General Li won a great victory. Now the head of state decide to reward him w ...

  9. Codeforces Round #682 (Div. 2) C. Engineer Artem (构造)

    题意:给你一个\(n\)x\(m\)的矩阵,你可以任意位置的元素+1,只能加一次,问你如何使得任意位置的元素不等于它四周的值.输出操作后的矩阵. 题解:构造,矩阵中某两个下标的和的奇偶性一定和四周的都 ...

  10. Gym 100803G Flipping Parentheses

    题目链接:http://codeforces.com/gym/100803/attachments/download/3816/20142015-acmicpc-asia-tokyo-regional ...