2018.06.13 15:09

nginx 301 api反向代理配置

nginx设置301永久重定向

server{
  listen 80;
  server_name www.textnuxt.lilidong.com textnuxt.lilidong.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.textnuxt.lilidong.com textnuxt.lilidong.com;
  root    /disk/wwwroot/vbloger/vue-blog;
  index    index.html;

  ssl on;
  ssl_certificate /disk/nginx/1_www.textnuxt.lilidong.com_bundle.crt;
  ssl_certificate_key /disk/nginx/2_www.textnuxt.lilidong.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;
  }
}







DIY表情

(添加http或https协议)

提交评论

留言区 3