[toc]
nginx常用命令
nginx -h #帮助
nginx -v #显示版本
nginx -V #显示版本和配置信息
nginx -t #测试配置
nginx -q #测试配置时,只输出错误信息
nginx -s stop #停止服务器
nginx -s reload #重新加载配置
安装nginx
yum install -y gcc gcc-c++ automake pcre pcre-devel zlip zlib-devel openssl openssl-devel
wget http://nginx.org/download/nginx-1.13.8.tar.gz
tar -zxvf nginx-1.13.8.tar.gz
cd nginx-1.13.8
./configure --prefix=/data/nginx --with-http_ssl_module --with-http_v2_module
make && make install
其他常用配置
小文件下载转换
location /converToLocalImg{
proxy_pass $arg_img;
proxy_redirect ~^(https?://gc-stor.bj.bcebos.*) /converToLocalImg?img=$1;
}
多域名跨域访问
location /restful {
if ( $http_origin ~ 'gaiay.net.cn' ){
add_header 'Access-Control-Allow-Origin' "$http_origin";
}
#add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
proxy_pass http://localhost:8084/restful;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
网友评论