Nginx反向代理静态资源

  •  在/etc/nginx/conf.d目录下创建test.conf文件,输入以下配置信息
​server {
    listen       80;
    server_name  helleworld.cn; #修改域名

    location / {
        root   /var/www/html; #代理到mall文件夹中
        index  index.html index.htm;
    }

    limit_rate 128k; #限制网速为128K

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

}
  • 配置 /etc/nginx/nginx.conf ,html里面输入以下配置信息
include /etc/nginx/conf.d/*.conf;
  • 重启nginx,systemctl restart nginx
  • 配置HTTPS
  • 在/etc/nginx/conf.d目录下创建ssl.conf文件,输入以下配置信息
server {
    listen       80; # 同时支持HTTP
    listen       443 ssl; # 添加HTTPS支持
    server_name  helleworld.cn;

    #SSL配置
    ssl_certificate      /root/c.crt; # 配置证书
    ssl_certificate_key  /root/c.key; # 配置证书私钥
    ssl_protocols        TLSv1 TLSv1.1 TLSv1.2; # 配置SSL协议版本
    ssl_ciphers          ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE; # 配置SSL加密算法
    ssl_prefer_server_ciphers  on; # 优先采取服务器算法
    ssl_session_cache    shared:SSL:10m; # 配置共享会话缓存大小
    ssl_session_timeout  10m; # 配置会话超时时间

    location / {
        root   /var/www/html;
        index  index.html index.htm;
    }

    location /admin {
        alias   /usr/share/nginx/html/admin;
        index  index.html index.htm;
    }

    location /app {
        alias   /usr/share/nginx/html/app;
        index  index.html index.htm;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
}

其中的需要手动生成SSL自签名证书并开启443端口。

参考:http://t.csdn.cn/elOcA

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值