Skip to content

Nginx 转发及替换

转发本地下载路径到其他CDN路径

nginx
    location ~* ^/file/ {
        rewrite ^/file/(.*)$ http://cdn.ioiox.com/file/$1 permanent;
    }

ngx_http_sub_module 直链文本替换

?> 查看源代码,替换相关href路径.

nginx
    location / {
        sub_filter '<a href="./test/'  '<a href="https://cdn.ioiox.com/test/';
        sub_filter '<a href = \'/test'  '<a href = \'https://cdn.ioiox.com/test/';
        sub_filter_once off;