安装和配置
nginx -v:查看版本
start nginx:启动 或双击exe
nginx -s reload:修改配置重启生效
nginx -s stop:快速停止
nginx -s quit:完整有序停止
nginx -s reopen:重新打开日志文件
简单配置版本
在conf
新建自定义的配置文件xxx.conf
并引入
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
#tcp_nopush on;
underscores_in_headers on; #反向代理时需要将请求头中带有下划线的参数也转发到代理目标
keepalive_timeout 65;
#gzip on;
include self/*.conf; #引入自定义conf配置文件
#server {
#listen 8080;
#server_name localhost;
#}
# another virtual host using mix of IP-, name-, and port-based configuration
#server {
#}
# HTTPS server
#server {
# listen 443 ssl;
#}
}
其中,xxx.conf
配置内容如下
server {
listen 8090;
server_name localhost;
//若以非url中字符标识,则proxy_pass带/, ^~或有
location ^~ /sqh {
proxy_pass http://facestat.paas.cmbchina.cn/;
}
//若以url中字符标识,则proxy_pass不带/, ^~或有
location ^~ /stat {
proxy_pass http://facestat.paas.cmbchina.cn;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location / {
root D:/server/tomcat/apache-tomcat-8.5.43/webapps; #或 root html
#autoindex on; #开启nginx目录浏览功能
index index.html index.htm;
}
}