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:
- Nginx configuration 80 can be accessed by forcing jump 443 or not
- Nginx Startup Error: “/var/run/nginx/nginx.pid” failed” [How to Solve]
- [Solved] nginx: [error] open() “/usr/local/nginx/nginx.pid” failed (2: No such file or directory)
- summary of configuration and deployment of uwsgi+nginx+flag in centos7 and why internal server error is prompted [official instructions]
- Nginx Error: Swap file “/etc/nginx/.nginx.conf.swp“ already exists
- Nginx Error: nginx: [emerg] the “ssl“ parameter requires ngx_http_ssl_module in /project/api/nginx.conf:
- Nginx error: nginx: [error] invalid PID number ““ in “/run/nginx.pid“
- [Solved] Nginx Restart Error: /run/nginx.pid failed (2: No such file or directory)
- Nginx Startup Error: Job for nginx.service failed because the control process exited with error code
- Nginx realizes the same background service for portal and business
- Solve the problem of 404 Not Found error in nginx accessing dynamic interface
- How to Fix No default.conf file in conf.d after Installing Nginx
- Nginx Reverse Proxy 426 Error [How to Fix]
- Nginx routes and forwards according to the URL and cuts the URL
- Restart and stop of nginx in Linux service
- Nginx Error: [emerg] bind() to [::]:80 failed (98: Address already in use)
- [Solved] Nginx Startup Error: directive is not allowed here in
- nginx: [emerg] bind() to 0.0.0.0:80 failed (13: Permission denied)
- Nginx, which is suitable for front-end H5 requests, routes and forwards according to the URL and cuts the URL
- tuxedo Compile Background Common Error [How to Fix]