小编Chr*_*her的帖子

覆盖单个位置块的 nginx 拒绝规则

我有一个像这样的 nginx 设置,其中服务器应该大部分是私有的(只有某些 IP 地址可以使用该服务器),除了一个location应该公开可用的块:

\n\n
server {\n  listen  443 ssl default;\n\n  # Allow access only from certain IP addresses\n  allow   12.34.56.78/32;\n  allow   10.0.2.2/32;\n  deny    all;\n\n  # Proxy dynamic requests to the app\n  location / {\n    proxy_pass  http://127.0.0.1:8000;\n  }\n  # Serve static assets from disk\n  location = /favicon.ico {\n    alias  /var/www/example.com/htdocs/static/images/favicon.png;\n  }\n  location /static {\n    alias  /var/www/example.com/htdocs/static;\n  }\n  ...\n\n  # Allow public access to this endpoint\n  location = /public/endpoint {\n    proxy_pass  http://127.0.0.1:9000;\n\n    # Allow *all* IPs here, so …
Run Code Online (Sandbox Code Playgroud)

nginx

6
推荐指数
1
解决办法
2万
查看次数

标签 统计

nginx ×1