Common configuration methods of nginx

nginx.conf

server 
   max-content-length

site-avalables site-enabled

The file name of this sample configuration file is Default
edit file: /etc/nginx/sites available/default

# If there are multiple servers, configure them here, and modify the proxy_pass 
upstream flask {
        server 127.0.0.1:5000;
        server 127.0.0.1:5001;
}
server {

        listen 80 default_server;
        listen [::]:80 default_server;
		
		# Set the maximum upload data size allowed by nginx service for users
		# Adjust the upload file size limit setting parameter according to business requirements
		client_max_body_size 10m;
		
        # Cache file size setting 0 means no limit
        # Use the default configuration, exceeding the size will result in an error.net::ERR_INCOMPLETE_CHUNKED_ENCODING error
        proxy_max_temp_file_size 0;

        root /var/www/html;

        index index.html index.htm index.nginx-debian.html;

        server_name _;

        location/{
                # Requests are forwarded to the gunicorn server
                proxy_pass http://127.0.0.1:5000;
                
                # Requests are forwarded to multiple gunicorn servers
                # proxy_pass http://flask;
                
                # Set the request header and pass the header information to the server side 
                proxy_set_header Host $host;
                
                # Set request header and pass original request ip to gunicorn server
                proxy_set_header X-Real-IP $remote_addr;
        }
}

Another way of writing

Modify the nginx configuration file so that nginx receives the request and forwards it to the uwsgi server


upstream test_server{
	server 10.211.55.2:8000;
}

#gzip  on;
server {
	listen  8000;
	server_name api.baidu.site;

	location/{
		include uwsgi_params;
		uwsgi_pass test_server;
	}

}

server {
	listen       80;
	server_name  www.baidu.site;

	#charset koi8-r;

	#access_log  logs/host.access.log  main;
	location /xadmin {
		include uwsgi_params;
		uwsgi_pass test_server;
 	}

	location /ckeditor {
		include uwsgi_params;
		uwsgi_pass test_server;
	}

	location/{
		root   /home/python/Desktop/front_end_pc;
		index  index.html index.htm;
	}

	error_page   500 502 503 504  /50x.html;
	location = /50x.html {
		root   html;
	}

}

Read More: