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

 

相关文章

Nginx (engine x) 是一个高性能的HTTP和反向代理服务,也是一...
本地项目配置 1 复制 luffy/settings/dev.py为prop.py 修改l...
nginx不仅可以隐藏版本信息,还支持自定义web服务器信息 先看...
一 、此次漏洞分析 1 nginx HTTP/2漏洞 [nginx-announce] ng...
###进入nginx 目录cd /usr/local/nginx###递归显示 2 级目录...
在cmd命令窗口输入下面命令进行查看 tasklist /fi "ima...