nginx配置

Nginx

安装配置

  1. 安装路径
    /usr/local/nginx/
  2. 配置⽂件
    /usr/local/nginx/conf/nginx.conf
  3. ⽇志路径
    在配置⽂件中指定,⽬前为: /usr/local/nginx/logs

修改配置操作

3.1
[root@P1QMSPL1RTM02 ~]# cd /usr/local/nginx/sbin/ # 执⾏行行⽂文件路路径
[root@P1QMSPL1RTM02 sbin]# ./nginx -t # 测试配置⽂文件
是否正确
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@P1QMSPL1RTM02 sbin]# ./nginx -s reload # 重载配置⽂文件

3.2 代理项⽬
3.2.1 QMS(默认)

upstream qms {
  server 10.50.10.151:8086;
  server 10.50.10.152:8086;
}
location / {
  root html;
  proxy_pass http://qms;
  proxy_set_header Host $host;
  proxy_set_header X-Real-IP $remote_addr;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  client_max_body_size 100m;
  proxy_read_timeout 600;
}

3.2.2 Report(/QMSReport)

upstream qmsreport {
  server 10.50.10.155:18080;
  server 10.50.10.155:28080;
  server 10.50.10.156:18080;
  server 10.50.10.156:28080;
  ip_hash;
}
location /QMSReport/ {
  proxy_pass http://qmsreport;
  proxy_set_header Host $host;
  proxy_set_header X-Real-IP $remote_addr;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  client_max_body_size 100m;
  proxy_read_timeout 600;
}

3.2.3 静态⽂件代理

location /smb/ {
  alias /dfs/acf/;
  expires 30d;
}
location /adsImgSmb/ {
  alias /dfs/oc/;
  expires 30d;
}
location /dfs/ {
  root /;
  expires 30d;
}
location /acf/ {
  root /dfs/;
  expires 30d;
}
location /oc/ {
  root /dfs/;
  expires 30d;
}

开启⽬录浏览功能

location /acf/ {
  autoindex on;
  autoindex_localtime on;
  root /dfs/;
  expires 30d;
}
posted @ 2022-04-06 22:41  journeyIT  阅读(37)  评论(0编辑  收藏  举报