Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kong: Requested URL return 204 instead of 200 #241

Closed
Bl4ckM opened this issue May 15, 2015 · 4 comments
Closed

Kong: Requested URL return 204 instead of 200 #241

Bl4ckM opened this issue May 15, 2015 · 4 comments

Comments

@Bl4ckM
Copy link

Bl4ckM commented May 15, 2015

Hi,
i try to forward all request from my client to my tomcat/http backend at 8081. I try to migrate kong into my project. If i POST a request to auth myself, i should get 200 with content-length:0 but i 'll get a 204 no content back. My POSTs pass through, but my Options went back with 204. I think it could be something wrong with your nginx.conf and your proxy_ settings. Any Ideas how to forward my requests to my api and get my originall 200 code instead of 204?

P.S: All went right @ access.log / error.log no problems at all.

Kong_proxy: running @ 8080
admin: running @ 8001

my restapp is deployed under:
http://localhost:8081/app
for requests:
http://localhost:8081/app/*

P.S2: Found and fix something, only Options get now 204, Posts get 200... Any Ideas?

api_config:

{
    "data": [
        {
            "public_dns": "localhost:8080",
            "id": "apikey",
            "target_url": "http://localhost:8081/",
            "name": "auth",
            "created_at": 1431682247000
        }
    ]
}

Plugin_config:

{
    "data": [
        {
            "api_id": "apikey",
            "id": "apikey",
            "value": {},
            "enabled": true,
            "name": "filelog",
            "created_at": 1431684868000
        },
        {
            "api_id": "apikey",
            "id": "apikey",
            "value": {
                "methods": "GET, HEAD, POST, PUT, DELETE, TRACE, OPTIONS, PATCH",
                "credentials": true,
                "exposed_headers": "Options,X-Auth-Token,Content-Type,Authorization,Accept,Accept-Version,Content-Length,Content-MD5,Date",
                "origin": "*",
                "preflight_continue": false,
                "headers": "Content-Type,X-Auth-Token,Authorization,Accept,Accept-Version,Content-Length,Content-MD5,Date,Options"
            },
            "enabled": true,
            "name": "cors",
            "created_at": 1431684414000
        }
    ]
}

normal Server-Return Header:

Accept: */*
Access-Control-Allow-Headers: Content-Type,X-Auth-Token,Authorization
Access-Control-Allow-Methods: POST, PUT, GET, OPTIONS, DELETE
Access-Control-Allow-Origin: *
Access-Control-Max-Age: 3600
Allow: GET, HEAD, POST, PUT, DELETE, TRACE, OPTIONS, PATCH
Content-Length: 0
Date: Fri, 15 May 2015 10:39:31 GMT
Server: Apache-Coyote/1.1
access-control-allow-credentials: true

Return Header with Kong-enabled:

Access-Control-Allow-Headers: Content-Type,X-Auth-Token,Authorization,Accept,Accept-Version,Content-Length,Content-MD5,Date,Options
Access-Control-Allow-Methods: GET, HEAD, POST, PUT, DELETE, TRACE, OPTIONS, PATCH
Access-Control-Allow-Origin: localhost
Connection: keep-alive
Date: Fri, 15 May 2015 10:30:48 GMT
Server: kong/0.2.1
Vary: Origin
Via: kong/0.2.1
access-control-allow-credentials: true
@thibaultcha
Copy link
Member

I see your config preflight_continue is set to false. By reading the code we can see the request is not being proxied but directly replies when this is set to false: https://github.com/Mashape/kong/blob/master/kong/plugins/cors/access.lua#L62

It is missing from the plugin's documentation but I guess you should set it to true if you want to preflight request to be proxied.

@thibaultcha
Copy link
Member

Even tho because of #203, I don't think the preflight requests can really be proxied, I will test this.

@Bl4ckM
Copy link
Author

Bl4ckM commented May 22, 2015

Even with preflight_continue=true i'll get only OPTIONS my post won't be sent through Kong..

@p0pr0ck5
Copy link
Contributor

My guess is this issue is so old there's nothing to be done here?

@p0pr0ck5 p0pr0ck5 closed this as completed Jul 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants