nginx进程(windows)
查看nginx进程
tasklist /fi "imagename eq nginx.exe"
杀掉nginx进程
taskkill /f /pid 25720 /pid 7556
常用命令
查看nginx的版本号
nginx -v
启动
start nginx
重载配置
nginx -s reload
快速停止或关闭
nginx -s stop
正常停止或关闭
nginx -s quit
常用配置
server{
# 设置本机监听的端口
listen 3868;
# 设置本机ip
server_name localhost;
client_max_body_size 20m;
location / {
root html;
index index.html index.htm;
client_max_body_size 20m;
} # 匹配到/apis开头的接口时,转发到下面的服务器地址
location /apis {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS';
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;
return 204;
}
if ($request_method = 'POST') {
add_header 'Access-Control-Allow-Origin' *;
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
}
if ($request_method = 'GET') {
add_header 'Access-Control-Allow-Origin' *;
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
}
# 匹配apis之后的路径和参数
rewrite ^.+apis/?(.*)$ /$1 break;
include uwsgi_params;
# 实际调用的API
proxy_pass http://4.103.63.13:8080;
}