cmdref.net - Cheat Sheet and Example

cmdref.net is command references/cheat sheets/examples for system engineers.

User Tools

Site Tools


Sidebar








Cloud



Etc


Reference














.

middleware:web:nginx:index.html



Middleware

Nginx Configuration Examples

References

Commands

Object Commands Environment Note
configtest nginx -t Ubuntu
RHEL7/CentOS7
Check Status systemctl status nginx RHEL7/CentOS7
Ubuntu20.04
Stop systemctl stop nginx RHEL7/CentOS7
Ubuntu20.04
Start systemctl start nginx RHEL7/CentOS7
Ubuntu20.04
[Ubuntu]sites-enabled
ln -s /etc/nginx/sites-available/aaa.example.com /etc/nginx/sites-enabled/aaa.example.com
ln -s /etc/nginx/sites-available/aaa.example.com /etc/nginx/sites-enabled/bbb.example.com


Install

Configuration

/etc/nginx/nginx.conf

Numbers of Core

You can set it to the same number cpu cores.

#grep processor /proc/cpuinfo | wc -l 
worker_processes 2;

maximum number of connections

It specifies the maximum number of connections that one of the worker process can be processed at the same time

#ulimit -n
events {
    worker_connections  1024;
}

hiding of nginx version

http {
        server_tokens off;


Virtual Host Configs(/etc/nginx/conf.d/*.conf | /etc/nginx/sites-enabled/*)

/etc/nginx/nginx.conf
    ##
    # Virtual Host Configs
    ##

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
Ubuntu
ln -s /etc/nginx/sites-available/aaa.example.com /etc/nginx/sites-enabled/aaa.example.com
ln -s /etc/nginx/sites-available/aaa.example.com /etc/nginx/sites-enabled/bbb.example.com

DocumentRoot

root   /usr/share/nginx/html;

VirtualServer

server {
    server_name example.com;

}

server {
    server_name example.com www.example.com;
}

server {
    server_name *.example.com;

}
Default Server
server {
    listen *:80 default_server;
    server_name example.com;
}

SSL

server {
    listen 443 ssl;

   (abbr)

    ssl on;
    ssl_certificate /etc/nginx/ssl/xxx.crt;
    ssl_certificate_key /etc/nginx/ssl/xxx.key;
    ssl_session_timeout 5m;
    ssl_ciphers 'AES128+EECDH:AES128+EDH:!aNULL';
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;

   (abbr)
}


Configuration Examples




middleware/web/nginx/index.html.txt ยท Last modified: 2021/02/15 by admin

Page Tools