美文网首页
nginx配置

nginx配置

作者: Aedda | 来源:发表于2021-06-28 14:42 被阅读0次
    1. 通用配置 被导入的配置
    # thomas.conf
        server {
          listen       80;
          server_name  thomas.com www.thomas.com;
          location / {
            proxy_pass http://127.0.0.1:8000;
            #  proxy_pass http://test.ifitment.cloud.suncentgroup.com:8084;
            proxy_set_header Host $host:80;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
       }
    
    1. 负载均衡配置 被导入的配置
    # oms.conf
        upstream django{
            server 127.0.0.1:8000 weight=1;
        }
        server {
          listen       80;
          server_name  thomas.com www.thomas.com;
          location / {
            proxy_pass http://127.0.0.1:8000;
            proxy_set_header Host $host:80;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
       }
    

    nginx.conf文件配置 nginx默认配置文件

    user nginx;
    worker_processes auto;
    error_log /var/log/nginx/error.log;
    pid /run/nginx.pid;
    
    include /usr/share/nginx/modules/*.conf;
    
    events {
        worker_connections 1024;
    }
    
    http {
        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  /var/log/nginx/access.log  main;
        #允许客户端请求的最大单文件字节数
        client_max_body_size 5m;
        #缓冲区代理缓冲用户端请求的最大字节数,
        client_body_buffer_size 128k;
        sendfile            on;
        tcp_nopush          on;
        tcp_nodelay         on;
        keepalive_timeout   65;
        types_hash_max_size 2048;
    
        include             /etc/nginx/mime.types;
        include             /etc/nginx/conf.d/*.conf;  # 再导入的配置中加上这些文件 server 被导入的内容就是1,2
        default_type        application/octet-stream;
    
    
    }
    

    相关文章

      网友评论

          本文标题:nginx配置

          本文链接:https://www.haomeiwen.com/subject/gytnlltx.html