SBotirov
SBotirov

Reputation: 14118

NGINX Rewrite url not works

I have following location with rewrite:

location ~ ^/payment/gateway/v2/order/complete/(.*)$ {
    proxy_pass http://api.test.com:8080/payment/gateway/v2/order/complete?order_id=$1;
}

then I tried this:

 location /payment/gateway/v2/order/complete {
    rewrite ^/payment/gateway/v2/order/complete/(.+) /payment/gateway/v2/order/complete?order_id=$1 break;
    proxy_pass http://api.test.com:8080
}

then this:

 location /payment/gateway/v2/order/complete/ {
    rewrite ^/payment/gateway/v2/order/complete/$ /payment/gateway/v2/order/complete?order_id=$1 last;
    proxy_pass http://api.test.com:8080
}

then this:

location /payment/gateway/v2/order/complete {
    rewrite ^/payment/gateway/v2/order/complete/([^/]+)$ /payment/gateway/v2/order/complete?order_id=$1 last;
    proxy_pass http://api.test.com:8080;
}

all of them not works.

Nginx version 1.13.8

Thanks in advance

EDIT All of code above works fine, I found my mistake. I copied one of configuration file to conf.d folder for backup but forgot rename it extension. I removed it and all works fine. Thank you for all for help!

Upvotes: 0

Views: 581

Answers (1)

Hyppo Drums
Hyppo Drums

Reputation: 111

nginx -V 2>&1 | tr -- - '\n' | grep  _module

This is how to ckeck installed modules. I have the same issue and looks like I don't have the module installed/enabled...

Upvotes: 1

Related Questions