如何编写具有命名位置的DRY模块化nginx conf(反向代理)
我主要将nginx用作几个gunicon / mod_wsgi应用程序前面的逆向代理,当然还用于服务器静态文件。 我发现我的nginx conf很快变得无法维护。问题是我有一些相似(甚至相同)的模式,但是我无法使其变得干净。 我遇到的最大问题之一是,我很想使用命名位置作为对一组conf进行分组的方法。 location @django_modwsgi { include proxy.conf; proxy_pass http://127.0.0.1:8080; } location @django_gunicorn { include proxy.conf; # this could also be included directly in the server {} block? proxy_pass http://gunicorn_builder; } 注意 问题不在于同时拥有gunicorn和wsgi。这只是一个例子。另一个是: location @namedlocation_1 { some cache settings; some cache_key settings; ignore some headers; expires; proxy_pass …