打开nginx所在目录
D:
cd nginx
然后就可以执行下面的命令了
start nginx // 启动Nginx
nginx -s stop // 停止nginx
nginx -s reload // 重新加载配置文件
nginx -s quit // 退出nginx
nginx在windows下设置网站时建议在conf
目录下新建一个conf.d
在nginx.conf
添加引用
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
server_names_hash_bucket_size 64;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
include D:/soft/nginx-1.8.1/conf/conf.d/*.conf;
}
引用配置的时候路径可以是绝对路径 类似于(注意斜杠的方向)
include D:/soft/nginx-1.8.1/conf/conf.d/*.conf;
也可以是
include conf.d/*.conf;
上面的配置要在
http
内部
但是以下两种是错误的
include ./conf.d/*.conf;
include /conf.d/*.conf;
upstream auth_psvmc {
server 192.168.0.214:8080;
ip_hash;
}
server {
listen 80;
server_name auth.psvmc.cn;
rewrite ^/auth/(.*)$ /$1 last;
location / {
proxy_pass http://auth_psvmc/auth/;
proxy_cookie_path /auth/ /;
proxy_redirect /auth/ /;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
}
}
我在配置后 报了如下错误
could not build the server_names_hash, you should increase server_names_hash_bucket_size: 32
解决方式
在http块中添加(如上面代码所示)
server_names_hash_bucket_size 64;