Open nginx.conf and configure it as you want. Here are some simple general tuning configurations

#user nobody; # worker_processes # worker_processes # worker_processes #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; Events {#== Max. CPU *2048 worker_connections 1024; } http { include mime.types; default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' # '$status $body_bytes_sent "$http_referer" ' #  '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; Keepalive_timeout 65; #gzip on; Server_names_hash_bucket_size 512; server_names_hash_bucket_size 512; Server_name = server_name = server_name = server_name = server_name = server_name = server_name = server_name = server_name = server_name Server_name localhost; Charset UTF-8; charset UTF-8; #access_log logs/host.access.log main; #location / {#location is the root of the site, which can be a relative path. You can also make the absolute path root HTML; HTML index.htm; # forward back-end site address, generally used to do soft load, polling backend server #proxy_pass http://10.11.12.237:8080; #deny all; #allow all; add_header 'Access-Control-Allow-Origin' '*'; add_header 'Access-Control-Allow-Credentials' 'true'; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type'; Proxy_set_header Host $Host; Proxy_set_header x-real-ip $remote_addr; $remote_ADDR adds the value of the $REMOTE_ADDR variable to the end of the client's X-Forwarded-For request header separated by a comma. If the request from the client does not carry the X-Forwarded-For header, $proxy_set_HEADER X-Forwarded-For $proxy_ADD_X_forwarded_for; Proxy_set_header Cookie $http_cookie; The primary domain and port number of the proxy server will be used instead. If the port number is 80, do not add. proxy_redirect off; If the Domain part of the Cookie does not match the Domain of the current page, it cannot be written. So if you request domain name A, server proxy_pass to domain name B, and then server B output the Cookie of Domian=B, # the front page still stays on domain name A, so the browser cannot write the Cookie. # Not only domain names, browsers also have restrictions on Path. We often pass proxy_pass to a Path on the target server, # not exposing this Path to the browser. In this case, if the target server's Cookie is dead, the Cookie cannot be written. The value can be a string, the pattern of a regular expression, or a variable referenced. The forwarding backend server will need to convert the Cookie domain if it needs cookies. If the front end domain name is inconsistent with the back end domain name, the cookie cannot be accessed. Proxy_cookie_domain localhost. Testcaigou800.com; proxy_cookie_domain localhost. # cancel all proxy_cookie_domain directives at the current configuration level Timeout for establishing a connection to the backend server. It can't be more than 75 seconds; proxy_connect_timeout 30; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; }} # if you need to listen for multiple domain names on the same port, use the following configuration: Server_names_hash_bucket_size Cache size server {listen 80; server_name www.abc.com; charset utf-8; location / { proxy_pass http://localhost:10001; } } server { listen 80; server_name aaa.abc.com; charset utf-8; location / { proxy_pass http://localhost:20002; }}}Copy the code

Nginx common command:

Help command: nginx -h

Start the Nginx server: sudo Nginx

Check the process: ps aux | grep nginx

Configuration file path: / usr/local/nginx/conf/nginx. Conf

Check the configuration file: sudo nginx -t

Specify the startup configuration file: sudo nginx – c/usr/local/nginx/conf/nginx. Conf

Violence stop service: sudo nginx -s stop

Gracefully stop service: sudo nginx -s quit

Reload the configuration file: sudo nginx -s reload

Reference Address:

1, www.cnblogs.com/taiyonghai/… .

2, www.nginx.cn/nginxchscom…

3, www.nginx.cn/doc/