# Nginx 配置文件提示 upstream 路径错误

**URL:** <https://www.isharkfly.com/t/nginx-upstream/17299>\
**Category:** DevOps\
**Tags:** nginx\
**Created:** [May 15, 2025, 2:55pm UTC](https://www.isharkfly.com/t/nginx-upstream/17299 "2025-05-15T14:55:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![hex](https://www.isharkfly.com/user_avatar/www.isharkfly.com/hex/32/21953_2.png) [@hex](https://www.isharkfly.com/u/hex)\
**Post date:** [May 15, 2025, 2:55pm UTC](https://www.isharkfly.com/t/nginx-upstream/17299/1 "2025-05-15T14:55:50Z")

</div>

错误的信息为：

```auto
nginx: [emerg] "upstream" directive is not allowed here 

```

## 原因和解决

这里的原因是改了配置文件upstream存的的位置不对所以导致报错的。

需要把 **upstream** 放入http 里面保存重启nginx就解决了。

 ![2025-05-15_10-55-31](https://cdn.isharkfly.com/com-isharkfly-www/discourse-uploads/original/3X/6/b/6b9334ceb98bd12cdfb4851b186bae4a58637b33.jpeg)
