Linux下nginx开发测试环境的单机速配-极简

Linux下nginx开发测试环境的单机速配-极简

安装nginx

# Centos  安装依赖
sudo yum install automake gcc gcc-c++ bzip2-devel readline-devel sqlite-devel zlib-devel openssl-devel gdbm-devel tk-devel xz-devel libffi-devel pcre pcre-devel -y
# 下载nginx
wget http://nginx.org/download/nginx-1.22.1.tar.gz
# 解压
tar -xvf nginx-1.22.1.tar.gz
# 安装及配置
./configure --prefix=/opt/soft/nginx
make -j4
make install

配置nginx

  1. 修改主配置文件
# 编辑主配置文件/opt/soft/nginx/conf/nginx.conf,在http块中的最后一行插入,注意分号不可缺
include /opt/soft/nginx/conf/dsconf/*.conf;
  1. 修改代理转发服务的配置
# /opt/soft/nginx/conf/dsconf,创建 my.test.cn.conf,并写入如下参考配置
server {
	# 端口
    listen  8082;
	# 域名
    server_name  my.test.cn
    root /opt/deploy/web/rman;
    access_log /opt/soft/nginx/logs/jdtest.dstest.cn_access.log main;
    error_log /opt/soft/nginx/logs/jdtest.dstest.cn_error.log debug;

    location ~ .*\.(gif|attach|exe|jpg|jpeg|png|bmp|swf|zip|cab|msi|rar|apk|pdf|doc|shtm|pkg|mp4|ogg|mp3|wav|ico|eot|otf|ttf|woff|woff2)$ {
        add_header Cache-Control "max-age=604831";
    }

    location ~ .*\.(js|css)?$ {
        add_header Cache-Control "private, max-age=604821";
    }

    location ~ .*\.(htm|html)?$ {
        add_header Cache-Control "private, no-store, no-cache, must-revalidate, proxy-revalidate";
    }

    location  ~.*\.(shtm)?$ {
      rewrite  ^/(.*).shtm  /$1.html;
    }

    location / {
    	# 默认访问index.html
        try_files $uri $uri/ /index.html;       	
        index index.html;
    }

    location /runnerapi/ {
    	# /runnerapi路径,默认转发给5001端口的/api/v1.0/
        proxy_http_version 1.1;
        proxy_set_header Connection "";
        proxy_set_header Host  $host:5001;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        proxy_pass http://172.16.1.5:5001/api/v1.0/;
    }
}
  • 13
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

说来世事不如闲~

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值