简体   繁体   English

如何在 nginx 中包含位置块?

[英]How to include location blocks in nginx?

I'm using nginx as a reverse proxy for 2 web apps.我使用nginx作为 2 个网络应用程序的反向代理。

Those 2 web apps (UI) are sharing location proxies, as the backend services are shared.这 2 个网络应用程序 (UI) 正在共享位置代理,因为后端服务是共享的。

How can I combine location blocks and include them in the servers?如何组合位置块并将它们包含在服务器中?

host.conf主机配置文件

server {
  server_name app1.com
  listen 8080;
  ...

  include /opt/bitnami/nginx/conf/vhosts/proxy.conf;
}

server {
  server_name app2.com;
  listen 8080;
  ...

  include /opt/bitnami/nginx/conf/vhosts/proxy.conf;
}

proxy.conf代理配置文件

location /api/videos {
  proxy_pass ...
}
...

But I am getting the following error:但我收到以下错误:

"location" directive is not allowed here in /opt/bitnami/nginx/conf/vhosts/proxy.conf:2

You need to change the file extension, change proxy.conf to proxy.locations .您需要更改文件扩展名,将proxy.conf更改为proxy.locations

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM