Answer the question
In order to leave comments, you need to log in
How to process a GET request in nginx?
I am very unfamiliar with Nginx, please help =(
There are links like
img.domain.ru/o/99/image.jpg
img.domain.ru/o/99/image.jpg?width=500&height=500
server {
listen 80;
server_name img.domain.ru;
location ~* \.(gif|jpg|png)$ {
proxy_pass http://imageserver;
image_filter crop $arg_width $arg_height;
error_page 415 = /empty;
}
# Error handler
location = /empty {
empty_gif; # Respond with empty image
}
}
# Backend image server
server {
listen 8082;
server_name localhost;
root /var/www/img.domain.ru;
rewrite ^/(.*)$ /$1 last;
}
# Upstream
upstream imageserver {
server localhost:8082;
}
Answer the question
In order to leave comments, you need to log in
location ~* \.(gif|jpg|png)$ {
proxy_pass http://imageserver;
if ($arg_width != "") { return 412; }
error_page 412 = @img;
error_page 415 = /empty;
}
location @img { image_filter crop $arg_width $arg_height; }
Make other URLs. For example:
img.domain.ru/o/99/image.jpg
img.domain.ru/o/99/800/600/image.jpg
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question