3

I have this default.conf:

server {
        listen  443 ssl;
        root /etc/nginx/json/;
        server_name    myserver.com;
        ssl_certificate /etc/ssl/certs/server.crt;
        ssl_certificate_key     /etc/ssl/private/server.key;
        ssl_protocols   TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers     HIGH:!aNULL:!MD5;
        location /platform/enabler/iam/token/generate/1.0.0
        {
                alias  /etc/nginx/json/generateToken.json;
        } }

calling the API with GET method the response is correct. calling the API with POST method the response is:

<html>
<head><title>405 Not Allowed</title></head>
<body bgcolor="white">
<center><h1>405 Not Allowed</h1></center>
<hr><center>nginx/1.14.2</center>
</body>
</html>

Please, could you help me?

2 Answers 2

3

You can add the following line to your config to make nginx serve the POST requests with static files:

error_page 405 =200 $uri;
Sign up to request clarification or add additional context in comments.

2 Comments

in which line of my configuration?
@sarjaana You can add it inside the location block to allow only /platform/enabler/iam/token/generate/1.0.0 POST request or to the server block to allow POST requests globally.
0

That solution didn't work for me, but what did was the following config (I'm using nginx as reverse proxy and everything dockerized)

    location / {
       include /etc/nginx/includes/common_location.conf;
       resolver 127.0.0.11 ipv6=off;
       set $upstream localhost:4200;
       proxy_pass http://$upstream;
    }

    location = /land {
       include /etc/nginx/includes/common_location.conf;
       proxy_method GET;
       resolver 127.0.0.11 ipv6=off;
       rewrite ^ https://example.com/land/ break;
    }

common_location.conf has the following:

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;
proxy_set_header    Host                $host;
proxy_set_header    X-Forwarded-Host    $host;
proxy_set_header    X-Forwarded-Port    $server_port;
proxy_set_header    Connection          $http_connection;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.