我有主机 nginx_host 使用以下 nginx.conf 托管 nginx
stream
{
server
{
listen 1234;
location / {
proxy_pass res_host1:1111;
}
location / {
proxy_pass res_host2:2222;
}
}
}
我运行 nginx nginx -s reload 我得到错误:
nginx: [emerg] "location" directive is not allowed here in /etc/nginx/nginx.conf:6
我希望 nginx 将 tcp 请求从 nginx_host:1234 重定向到 res_host1:1111,如果它关闭,则重定向到 res_host2:2222;我究竟做错了什么?如何解决?
结果,我在 /etc/nginx/nginx.conf 中这样写:
我希望这可以帮助某人更快地设置 nginx。