Reverse proxy
The program listens to port 5244 by default. If you do reverse proxy
, recommended you set site_url so that alist can works fine.
If you want to use a sub folder, refer to reverse proxy with sub folder
nginx
nginx
Add in the server field of the website configuration file
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Range $http_range;
proxy_set_header If-Range $http_if_range;
proxy_redirect off;
proxy_pass http://127.0.0.1:5244;
# the max size of file to upload
client_max_body_size 20000m;
}
```
在网站配置文件的 server 字段中添加
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Range $http_range;
proxy_set_header If-Range $http_if_range;
proxy_redirect off;
proxy_pass http://127.0.0.1:5244;
# the max size of file to upload
client_max_body_size 20000m;
}
WARNING注意
If you use the bt.cn, be sure to delete the following default configuration
- location ~ ^/(.user.ini|.htaccess|.git|.svn|.project|LICENSE|README.md
- location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$
- location ~ .*.(js|css)?$
WARNING注意
如果使用宝塔面板,请务必删除以下默认配置
- location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md
- location ~ .\*\.(gif|jpg|jpeg|png|bmp|swf)$
- location ~ .\*\.(js|css)?$
并在/www/server/nginx/conf/proxy.conf
中或对应网站配置文件中设置禁用Nginx缓存,否则默认配置下访问较大文件时Nginx会先尝试将远程文件缓存至本机,导致播放失败
proxy_cache cache_one; # 删除这一行
proxy_max_temp_file_size 0; #加上这一行
Disable Nginx caching in /www/server/nginx/conf/proxy.conf
or the corresponding website configuration file. Otherwise, with the default configuration, when accessing large files, Nginx will attempt to cache the remote file locally first, resulting in playback failures.
proxy_cache cache_one; # Remove this line
proxy_max_temp_file_size 0; # Add this line
如果需要使用HTTP/3,需要将对应`HOST`行修改为:
```bash title="conf"
proxy_set_header Host $host:$server_port;
```
这样修改后的配置同时也可以兼容HTTP/2及更低版本的请求。
Apache
Apache
Add the anti-generation configuration item ProxyPass under the VirtualHost field, such as:
<VirtualHost *:80>
ServerName myapp.example.com
ServerAdmin webmaster@example.com
DocumentRoot /www/myapp/public
AllowEncodedSlashes NoDecode
ProxyPreserveHost On
ProxyPass "/" "http://127.0.0.1:5244/" nocanon
ProxyPassReverse "/" "http://127.0.0.1:5244/" nocanon
</VirtualHost>
在 VirtualHost 字段下添加配置项 ProxyPass,如:
<VirtualHost *:80>
ServerName myapp.example.com
ServerAdmin webmaster@example.com
DocumentRoot /www/myapp/public
AllowEncodedSlashes NoDecode
ProxyPreserveHost On
ProxyPass "/" "http://127.0.0.1:5244/" nocanon
ProxyPassReverse "/" "http://127.0.0.1:5244/" nocanon
</VirtualHost>
Caddy
Caddy
Add the reverse_proxy configuration item reverse_proxy under the Caddyfile file, for example:
:80 {
reverse_proxy 127.0.0.1:5244
}
在 Caddyfile 文件下添加 reverse_proxy,如:
:80 {
reverse_proxy 127.0.0.1:5244
}
如果部署在 443 端口正常使用的服务器上且使用域名进行访问,建议使用这种配置让 Caddy 自动申请证书:
example.com {
reverse_proxy 127.0.0.1:5244
}
将 `example.com` 替换为你自己解析后的域名。
Demonstration of Setting up Reverse Proxy in BT Panel
宝塔设置反向代理示范
1.Login to the BT panel and add a new website.
1.登录宝塔面板,添加站点;


2.Modify the website settings.
2.修改站点设置;


3.Remove the default panel code.
3.删除面板默认代码;
4.Add the reverse proxy.
4.添加反向代理;

If you need to apply for an
SSL certificate
, you can first apply for the certificate in theSSL
option, and then set up the reverse proxy. Alternatively, you can set up the reverse proxy first, disable the proxy function, apply for anSSL
certificate, and then enable the proxy again.

如需申请
SSL
证书,可先在SSL
选项中申请证书,然后在设置反向代理。或者设置反向代理之后,关闭反向代理功能,申请SSL
证书后再次开启代理。