I have an app that connects various payment gateways. When payment gateway navigates back to my site using url example.com/after-payment-success or example.com/after-payment-failed I get a 405 not allowed from Nginx.
If I visit the page direct from my browser there is no problem also when I refresh the exact same page with the 405 error it loads perfectly fine.
It seems to be related to programmatic redirection to my site from payment gateway.
Details: Site is hosted in a AWS which redirects to http Nginx .Also the payment request goes from my ionic App to another apache server first then to payment gateway.While returning PG redirects to apache and then to my app
Below is the configuration
proxy_headers_hash_max_size 512;
proxy_headers_hash_bucket_size 128;
large_client_header_buffers 8 64k;
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
try_files $uri $uri/ /index.html;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
Try this location
block instead:
location / {
error_page 405 =200 $uri;
try_files $uri $uri/ /index.html;
}
Since you don't use the functionality of ngx_http_proxy_module
, you don't need that proxy_set_header
directives (though they are not the reason of this error).