powerful! Nginx configuration online one-click generation "artifact"

image

As a lightweight HTTP server, Nginx has obvious advantages over Apache. In terms of performance, it occupies less resources and can support higher and more concurrent connections, thereby improving access efficiency; in terms of function, it is a Very good proxy server and load balancing server; it is installed in the installation configuration, the configuration is relatively simple.

image

A lot of articles on Nginx deployment and configuration have been published on the official account. There are many articles, so I won’t list them one by one. Those who are interested and in need can go to the official account to find related articles through the search function.

For a detailed explanation of some configurations of Nginx, I have written related articles before:

Detailed Nginx optimized configuration

However, in the actual production configuration environment, you will definitely encounter the problem of needing to modify or re-add the Nginx configuration. Sometimes the requirements are more diverse. There are often some errors of this and that in the modification and modification, especially Troublesome.

Based on the above reasons, it is certain that many reader partners will often collect some configuration files or save some of their daily common configuration cases in the computer, but it is still not very convenient after all. Today, Migrant Workers introduces a "super awesome artifact" that can generate Nginx configuration online with one click.

image

Website: https://nginxconfig.io/

NGINX Config supports various configuration options such as HTTP, HTTPS, PHP, Python, Node.js, WordPress, Drupal, caching, reverse proxy, logging, etc. Generate web server Nginx configuration file online.

The operation configuration is also very simple, you only need to do 2 steps:

  • Open the official website 

  • Configure related parameters as required

The system will automatically generate a specific configuration file. Although the interface is in English, the functional page is very intuitive, and the generated Nginx format specification.

The approximate interface after login is as follows:

image

Case show

Configure the domain name: mingongge.com realizes that when users access the *.mingongge.com domain name, they will automatically jump to this configuration of mingongge.com, and enable the configuration of http forced redirect to https.

image

image

At this time, the Nginx configuration will be automatically generated below in real time. I copied the generated configuration as follows:

/etc/nginx/sites-available/mingongge.com.conf#文件名都给你按规则配置好了
server {
listen 443 ssl http2;

server_name mingongge.com;

# SSL
ssl_certificate /etc/letsencrypt/live/mingongge.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mingongge.com/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/mingongge.com/chain.pem;

# security
include nginxconfig.io/security.conf;

# additional config
include nginxconfig.io/general.conf;
}

# subdomains redirect
server {
listen 443 ssl http2;

server_name *.mingongge.com;

# SSL
ssl_certificate /etc/letsencrypt/live/mingongge.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mingongge.com/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/mingongge.com/chain.pem;

return 301 https://mingongge.com$request_uri;
}

# HTTP redirect
server {
listen 80;

server_name .mingongge.com;

include nginxconfig.io/letsencrypt.conf;

location / {
return 301 https://mingongge.com$request_uri;
}
}

Very convenient and fast.

The official also provides some basic optimization configurations of Nginx, as follows:

/etc/nginx/nginx.conf
# Generated by nginxconfig.io

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;

#
 load configs
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}

There are also security-based configurations, as follows:

/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 * data: 'unsafe-eval' 'unsafe-inline'" always;

# . files
location ~ /\.(?!well-known) {
deny all;
}

Both are equivalent to providing some basic template configuration, which can be modified according to your actual needs.

With this artifact in hand, you no longer have to worry about configuring various configurations of Nginx! ! Brother migrant workers don’t dare to hide such a good artifact in his hands. I will share it with you today. Readers and friends who feel helpful should remember to forward and share it , thanks for your support! ! !


Guess you like

Origin blog.51cto.com/15065848/2575886