您当前的位置:首页 > 计算机 > 服务器 > Nginx

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

时间:08-18来源:作者:点击数:
CDSY,CDSY.XYZ

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;
    }
}

 

CDSY,CDSY.XYZ
方便获取更多学习、工作、生活信息请关注本站微信公众号城东书院 微信服务号城东书院 微信订阅号
推荐内容
相关内容
栏目更新
栏目热门
本栏推荐