当前位置:首页 > 运维笔记 > 正文内容

Nginx 代理Alist规则

#PROXY-START/

location ^~ /
{
    proxy_pass http://127.0.0.1:5244/d/;
    proxy_set_header Host 127.0.0.1;
    proxy_set_header AA "some_value";
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header REMOTE-HOST $remote_addr;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $connection_upgrade;
    proxy_http_version 1.1;
    # proxy_hide_header Upgrade;

    #more_set_headers 'Content-Type: image/jpeg';
    #add_header Content-Disposition "attachment";
    #add_header Content-Type "image/jpeg";
    #add_header 'Content-Type: image/jpeg';
    #add_header X-Cache $upstream_cache_status;
    #Set Nginx Cache

    set $static_file5O8ITIuJ 0;
    
    if ( $uri ~* "\.(gif|png|jpg|css|js|woff|woff2)$" )
    {
        set $static_file5O8ITIuJ 1;
        expires 1m;
    }
    if ( $static_file5O8ITIuJ = 0 )
    {
        add_header Cache-Control no-cache;
    }
    if ( $uri )
    {
      # 更改所有请求返回图片... 
      add_header Content-Disposition "attachment";
      add_header Content-Type "image/jpeg";
    }
    if ( $uri ~* "\.(mp3||flac)$" )
    {
      add_header Content-Disposition "inline";
      add_header Content-Type "audio/mpeg";
    }
    if ( $uri ~* "\.(mp4||mkv)$" )
    {
      add_header Content-Disposition "inline";
      add_header Content-Type "video/mp4";
    }
    
    location = / {
        deny all; # 拒绝访问首页
    }
}
#PROXY-END/


简单说两句

访客

◎ 不想说话可以不说,说了便要负责!