微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

centos7 nginx location 配置

Nginx 安装

 

yum install -y epel-release

yum –y install Nginx

systemctl start Nginx

systemctl enable Nginx

 

注释掉 /etc/Nginx.conf 认监听的80端口

新建文件 vim /etc/conf.d/xxxxx.conf

server {
    listen       443 ssl http2;
    listen       [::]:443 ssl http2;
    server_name  demo.com;

    ssl_certificate /etc/letsencrypt/live/demo.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/demo.com/privkey.pem;
    proxy_redirect     off;
    proxy_http_version 1.1;
    proxy_cache_bypass $http_upgrade;
    proxy_set_header   Upgrade $http_upgrade;
    proxy_set_header   Connection keep-alive;
    proxy_set_header   Host $host;
    proxy_set_header   X-Real-IP $remote_addr;
    proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header   X-Forwarded-Proto $scheme;
    proxy_set_header   X-Forwarded-Host $server_name;


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

    # Configure the SignalR Endpoint
    location /api/ {
      proxy_pass http://localhost:8800/;
    }
 }



server {
    listen 80;
    server_name demo.com;
    return 301 https://$server_name$request_uri;
}

 

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐