Linux下nginx开发测试环境的单机速配-极简
安装nginx
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
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
- 修改主配置文件
include /opt/soft/nginx/conf/dsconf/*.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 / {
try_files $uri $uri/ /index.html;
index index.html;
}
location /runnerapi/ {
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/;
}
}