This website requires JavaScript.

nginx 301 api反向代理配置

2018.04.08 11:37字数 1218阅读 335喜欢 0评论 0
server{
    listen 80;
    server_name  www.ouyang90.com ouyang90.com;
    #告诉浏览器有效期内只准用 https 访问
    add_header Strict-Transport-Security max-age=15768000;
    #永久重定向到 https 站点
    return 301 https://$server_name$request_uri;
}

server {
    charset utf-8;
    client_max_body_size 128M;

    #listen 80; ## 监听 ipv4 上的 80 端口
    listen 443;
    #listen [::]:80 default_server ipv6only=on; ## 监听 ipv6 上的 80 端口

    server_name www.ouyang90.com ouyang90.com;
    root        /disk/wwwroot/vbloger/vue-blog;
    index       index.html;

    ssl on;
    ssl_certificate /disk/nginx/1_www.ouyang90.com_bundle.crt;
    ssl_certificate_key /disk/nginx/2_www.ouyang90.com.key;
    ssl_session_timeout 5m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #按照这个协议配置
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;#按照这个套件配置
    ssl_prefer_server_ciphers on;

    location / {
        proxy_set_header   Host      $host;
        proxy_set_header   X-Real-IP $remote_addr;
        proxy_pass         http://127.0.0.1:3000;
    }

    location ^~ /api/ {
        proxy_set_header   Host      $host;
        proxy_set_header   X-Real-IP $remote_addr;
        proxy_pass         http://127.0.0.1:8000;
    }
}