@
@
@greedline2021-03-14 11:26:36
Nginx
@greedline, 2021-03-14 11:26:36

How to implement the return of different files to HTTP requests at the same URL?

Good day!

I have a task - to send different files from the server using NGINX to HTTP requests whose headers contain different data (in our case it will be a custom header with a number as a value that will also be stored in the database).
The question is:
Is it possible to implement a similar design using only NGINX?

Thank you in advance for your response.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Sokolov, 2021-03-14
_

For the "X-User-File" header, something like:

http {
  # ...
  map $http_x_user_file  $kinofile {
    default 'error.txt';
 
    kino1    movie1.mp4;
    kino2    old/TheMatrix.avi;
  }

  server {
    # ...
    location /film {
      try_files /movies/$kinofile  =404;

ps with the NGINX database can work with the help of add. modules, such as arut/nginx-mysql-module , but this solution is unlikely to suit you. So it's probably better to auto-generate the nginx config from the database, updating that blockmap

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question