nginx配置代理文件、反向代理配置

nginx配置代理文件、反向代理配置

 

server {
    listen 80;
    listen 443 ssl;
    # 域名
    server_name asgcode.test.com; 
    ssl on;
    ssl_certificate   /home/test/aiphoto_data_maintain/run/ssl/server.crt;
    ssl_certificate_key  /home/test/aiphoto_data_maintain/run/ssl/server.key;
    ssl_client_certificate /home/test/aiphoto_data_maintain/run/ssl/root.crt;
    ssl_verify_client on;
    ssl_session_timeout 5m;
    client_max_body_size 20m;
    # https
    #ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;
    access_log /data/asgcode/logs/nginx/access.log main;
    error_log  /data/asgcode/logs/nginx/error.log;

#location /myfiles/ {
#     alias /home/test/test_file/;
#     autoindex on;               # 自动列出目录下的文件;
#     autoindex_exact_size off;   # 文件大小按 G、M 的格式显示,而不是 Bytes;
#     add_header Access-Control-Allow-Origin *;
#     add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept";
#     add_header Access-Control-Allow-Methods "GET, POST, OPTIONS";
#}

#代理文件
location /static/save_image/ {  
        alias /home/zhaoyingjie/aiphoto_data_maintain/static/save_image/;
        add_header Access-Control-Allow-Origin *;
        add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept";
        add_header Access-Control-Allow-Methods "GET, POST, OPTIONS";
}

# 显示文件
location /testdetect/ { 
        alias /home/zhaoyingjie/aiphoto_data_maintain/static/detect/;
        index index.html;
        add_header Access-Control-Allow-Origin *;
        add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept";
        add_header Access-Control-Allow-Methods "GET, POST, OPTIONS";
}

# 反向代理
location / { 

    add_header Access-Control-Allow-Origin *;
    add_header Access-Control-Allow-Methods "POST,GET,OPTIONS";
    #add_header Access-Control-Allow-Headers x-requseted-with,content-type;
    add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept";
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-For $remote_addr;
    proxy_headers_hash_max_size 51200;
    proxy_headers_hash_bucket_size 6400;
    set_real_ip_from 0.0.0.0/0;
    real_ip_header  X-Forwarded-For;
    include  uwsgi_params;
    uwsgi_pass 127.0.0.1:7060;
    }
}

 

posted on 2021-10-15 21:22  星河赵  阅读(49)  评论(0编辑  收藏  举报

导航