最近用服务器反代本地的视频,发现音乐可以播放,但视频始终没法播放,百思不得其解,后面找了很久,终于找到了,贴个代码记录下。
在宝塔设置好反向代理后,把反向代理的配置文件全都删除,复制如下代码粘贴进去,把里面两处 proxy_pass http://ip:port 修改为你要反代的ip或者域名
#PROXY-START/ location ~* \.(gif|png|jpg|css|js|woff|woff2)$ { proxy_pass http://ip:port; proxy_set_header Host $host; 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; expires 12h; } client_max_body_size 5000M; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For '$proxy_add_x_forwarded_for'; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Sec-WebSocket-Extensions $http_sec_websocket_extensions; proxy_set_header Sec-WebSocket-Key $http_sec_websocket_key; proxy_set_header Sec-WebSocket-Version $http_sec_websocket_version; proxy_cache off; proxy_redirect off; proxy_buffering off; location / { proxy_pass http://ip:port; proxy_set_header X-Forwarded-For $remote_addr; proxy_ssl_verify off; proxy_http_version 1.1; proxy_set_header Host $http_host; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_read_timeout 86400; } #PROXY-END/
请登录之后再进行评论