设置nginx反向代理集群时:"upstream" directive is not allowed here in H:\nginx-1.12.2-Server/conf/nginx.conf:81

首先要知道“upstream”配置的位置应该是在 http 模块下,其次应该在server模块外,不可以在server模块下

这是报错时候的配置文件:

server {
        listen       8080;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
        #    root   html;
        #    index  index.html index.htm;
			proxy_pass http://myServer;
        }
		
		upstream myServer{
			server 127.0.0.1:8081;
			server 127.0.0.1:8082;
			server 127.0.0.1:8083;
		}
	
    }

这是改正之后的:

server {
        listen       8080;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
        #    root   html;
        #    index  index.html index.htm;
			proxy_pass http://myServer;
        }
		
    }

#这里把upstream放到server模块外边
upstream myServer{
			server 127.0.0.1:8081;
			server 127.0.0.1:8082;
			server 127.0.0.1:8083;
		}

ok!正常启动

你可能感兴趣的:(环境和服务问题)