O
O
Oleg Ilyin2016-07-21 10:12:12
Nginx
Oleg Ilyin, 2016-07-21 10:12:12

How to make a redirect in nginx if the user sends a file?

There are two servers: application server and file server.
There are many methods that save files on the server.
You need to do this: when the user submits the form (it is located on the application server) to save the file, the entire request must be proxied to the file server while maintaining the same url
How to determine that the user sent a POST request to save the file?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eugene D., 2016-08-21
@devg

It can be determined using an additional condition in the location section.
For example, like this:

location /postfiles {
  # проксируем post-запросы
  if ($request_method ~ ^(POST)$ ) {
    proxy_pass  http://fileserver.com/postfiles/$is_args$args;
    break; 
  } 
  
  #тут обработка остальных, не-post запросов
  try_files $uri $uri/ /index.php?$query_string;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question