1

I should make a conditional rediction in nginx. I would like to do something like that.

$http_code = code from curl commande

if ( $http_code = 200 ){

"redirection to server 1"

}

else {

"redirection to server 2"

}

So can someone help me to find a way to do it, or give me example of nginx conf with condition like this.

Thanks

khaled
  • 21
  • 1
  • https://serverfault.com/questions/1003406/how-can-i-do-a-redirect-with-404-as-status-code-in-nginx the same imho can be used for any other – djdomi Jun 23 '21 at 09:29
  • I have already seen this post and it does not answer my request, because i want to make a test and the rediction will be to another server depending to result – khaled Jun 23 '21 at 09:50
  • location = /foo { error_page 404 = @ext_404; } location @ext_404 { proxy_pass https://bar.example.com; it does not answer it? it DOES – djdomi Jun 23 '21 at 09:53
  • You can join me on https://chat.stackexchange.com/rooms/126791/thechat and we will discuss this sutation with some words – djdomi Jun 23 '21 at 09:55
  • Thank you for your proposal, but i don't have enough of right to acces to the chat – khaled Jun 23 '21 at 10:03
  • now oyu should :-) – djdomi Jun 23 '21 at 10:04
  • i have this message "You must have 20 reputation on The Stack Exchange Network to talk here" that's why i can't be on the chat – khaled Jun 23 '21 at 11:42
  • I don't think basic nginx has feature to implement such conditional processing based on results on requests to other parts. You need to use either nginx JS module or LUA module with an appropriate script to implement this logic. – Tero Kilkanen Jun 23 '21 at 15:41

0 Answers0