代码之家  ›  专栏  ›  技术社区  ›  sanyassh Khushboo Tahir

如何通过curl从nginx获取静态文件?

  •  0
  • sanyassh Khushboo Tahir  · 技术社区  · 6 年前

    我有这个nginx配置:

    server {
    listen 80;
    client_max_body_size 4G;
    
    server_name mysite.ru;
    
    location / {
      proxy_set_header Host $http_host;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_redirect off;
      proxy_buffering off;
      proxy_pass http://aiohttp;
    }
    
    location /static {
      # path for static files
      root /var/www/mysite.ru/public_html;
    }
    }
    

    我有索引。html在/var/www/mysite中。ru/public_html。如何通过curl获取此文件?这些都不起作用:

    curl-xget' http://mysite.ru/static/index.html '

    http://mysite.ru/index.html '

    1 回复  |  直到 6 年前
        1
  •  2
  •   Richard Smith    6 年前

    curl-xget' http://mysite.ru/static/index.html '

    使用当前配置,将在以下位置搜索此文件: /var/www/mysite.ru/public_html/static/index.html . 请注意,该位置是通过连接 root 值与URI一起使用。看见 this document


    http://mysite.ru/index.html '

    此请求将发送到上游 aiohttp 服务


    /static/ 在路径名中,使用 alias 指令:

    location /static {
        # path for static files
        alias /var/www/mysite.ru/public_html;
    }
    

    看见 this document 更多。