P
P
popopa2018-08-20 16:14:38
Nginx
popopa, 2018-08-20 16:14:38

How to set up rewrite of images from the /upload/ folder using nginx?

Need help compiling a rewtite or location for nginx to redirect all images from the upload folder to another domain.
Namely example.com/upload/folder/somefolder/onemorefolder/name.(png|jp?g)
on ​​images.example.com/folder/somefolder/onemorefolder/name.(png|jp?g)
That is, we cut /upload / and redirect to images.example.com

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
fso, 2018-08-20
@fso

Correct the regulators if necessary.

location /upload {
    rewrite ^/upload/(.*)$ https://images.example.com/$1 break;
    return 404;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question