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

Nginx upstream reverse proxy pending request #26

Open
igordeveloper opened this issue Oct 29, 2023 · 0 comments
Open

Nginx upstream reverse proxy pending request #26

igordeveloper opened this issue Oct 29, 2023 · 0 comments

Comments

@igordeveloper
Copy link

igordeveloper commented Oct 29, 2023

Hi everyone.

I'm getting a error using the nginx reverse proxy for freddie bundle, the response from subscriber controller remains pending and i cant get he response header status.

If i sent a request direclty to react server the response header is running.


Request URL:
http://localhost:4001/.well-known/mercure?topic=test
Request Method:
GET
Status Code:
200 OK
Remote Address:
[::1]:4001
Referrer Policy:
strict-origin-when-cross-origin

HTTP/1.1 200 OK
Content-Type: text/event-stream
Server: ReactPHP/1
Date: Sun, 29 Oct 2023 17:41:06 GMT
Transfer-Encoding: chunked

But, if I send a request to the nginx server i cant receive a response from the server, the Chrome DevTools inform the pendins status.

Request URL:
http://localhost:4000/.well-known/mercure?topic=test
Referrer Policy:
strict-origin-when-cross-origin  

Follow my nginx configuration

upstream freddie {
    server 127.0.0.1:4001;
}

server {

    listen 4000;
    server_name _;

    location / {
        # Simple requests
        if ($request_method ~* "(GET|POST)") {
          add_header "Access-Control-Allow-Origin"  *;
        }

        # Preflighted requests
        if ($request_method = OPTIONS ) {
          add_header "Access-Control-Allow-Origin"  *;
          add_header "Access-Control-Allow-Methods" "GET, POST, OPTIONS, HEAD";
          add_header "Access-Control-Allow-Headers" "Authorization, Origin, X-Requested-With, Content-Type, Accept";
          return 200;
        }

        proxy_pass http://freddie;
        proxy_read_timeout 24h;
        proxy_http_version 1.1;
        proxy_set_header Connection "";
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

Follow nginx debug log:

2023/10/29 18:08:59 [debug] 29#29: *3 http run request: "/.well-known/mercure?topic=test"
2023/10/29 18:08:59 [debug] 29#29: *3 http upstream check client, write event:0, "/.well-known/mercure"
**2023/10/29 18:08:59 [info] 29#29: *3 epoll_wait() reported that client prematurely closed connection, so upstream connection is closed too while reading upstream, client: 192.168.0.1, server: _, request: "GET /.well-known/mercure?topic=test HTTP/1.1",** upstream: "http://127.0.0.1:4001/.well-known/mercure?topic=test", host: "localhost:4000"
2023/10/29 18:08:59 [debug] 29#29: *3 finalize http upstream request: 499
2023/10/29 18:08:59 [debug] 29#29: *3 finalize http proxy request
2023/10/29 18:08:59 [debug] 29#29: *3 free rr peer 1 0
2023/10/29 18:08:59 [debug] 29#29: *3 close http upstream connection: 19
2023/10/29 18:08:59 [debug] 29#29: *3 free: 000055BC9DB54E60, unused: 48
2023/10/29 18:08:59 [debug] 29#29: *3 event timer del: 19: 216919881
2023/10/29 18:08:59 [debug] 29#29: *3 reusable connection: 0
2023/10/29 18:08:59 [debug] 29#29: *3 http upstream temp fd: -1
2023/10/29 18:08:59 [debug] 29#29: *3 http finalize request: 499, "/.well-known/mercure?topic=test" a:1, c:1
2023/10/29 18:08:59 [debug] 29#29: *3 http terminate request count:1
2023/10/29 18:08:59 [debug] 29#29: *3 http terminate cleanup count:1 blk:0
2023/10/29 18:08:59 [debug] 29#29: *3 http posted request: "/.well-known/mercure?topic=test"
2023/10/29 18:08:59 [debug] 29#29: *3 http terminate handler count:1
2023/10/29 18:08:59 [debug] 29#29: *3 http request count:1 blk:0
2023/10/29 18:08:59 [debug] 29#29: *3 http close request
2023/10/29 18:08:59 [debug] 29#29: *3 http log handler
2023/10/29 18:08:59 [debug] 29#29: *3 geoip2 http log handler
2023/10/29 18:08:59 [debug] 29#29: *3 free: 000055BC9DB72CB0
2023/10/29 18:08:59 [debug] 29#29: *3 free: 000055BC9DBCA870, unused: 2
2023/10/29 18:08:59 [debug] 29#29: *3 free: 000055BC9DBB8A00, unused: 5
2023/10/29 18:08:59 [debug] 29#29: *3 free: 000055BC9DB73CC0, unused: 3022
2023/10/29 18:08:59 [debug] 29#29: *3 close http connection: 21
2023/10/29 18:08:59 [debug] 29#29: *3 reusable connection: 0
2023/10/29 18:08:59 [debug] 29#29: *3 free: 000055BC9DB6DA90
2023/10/29 18:08:59 [debug] 29#29: *3 free: 000055BC9DB6B230, unused: 136
2023/10/29 18:08:59 [debug] 29#29: accept on 0.0.0.0:4000, ready: 0
2023/10/29 18:08:59 [debug] 29#29: posix_memalign: 000055BC9DB6B230:512 @16
2023/10/29 18:08:59 [debug] 29#29: *6 accept: 192.168.0.1:57462 fd:19
2023/10/29 18:08:59 [debug] 29#29: *6 event timer add: 19: 60000:130773327
2023/10/29 18:08:59 [debug] 29#29: *6 reusable connection: 1
2023/10/29 18:08:59 [debug] 29#29: *6 epoll add event: fd:19 op:1 ev:80002001
2023/10/29 18:08:59 [debug] 29#29: *6 http wait request handler
2023/10/29 18:08:59 [debug] 29#29: *6 malloc: 000055BC9DB6DA90:1024
2023/10/29 18:08:59 [debug] 29#29: *6 recv: eof:0, avail:-1
2023/10/29 18:08:59 [debug] 29#29: *6 recv: fd:19 702 of 1024
2023/10/29 18:08:59 [debug] 29#29: *6 reusable connection: 0
2023/10/29 18:08:59 [debug] 29#29: *6 posix_memalign: 000055BC9DBCA870:4096 @16
2023/10/29 18:08:59 [debug] 29#29: *6 http process request line
2023/10/29 18:08:59 [debug] 29#29: *6 http request line: "GET /.well-known/mercure?topic=test HTTP/1.1"
2023/10/29 18:08:59 [debug] 29#29: *6 s:0 in:'2F:/'
2023/10/29 18:08:59 [debug] 29#29: *6 s:1 in:'2E:.'
2023/10/29 18:08:59 [debug] 29#29: *6 s:2 in:'77:w'
2023/10/29 18:08:59 [debug] 29#29: *6 s:0 in:'65:e'
2023/10/29 18:08:59 [debug] 29#29: *6 s:0 in:'6C:l'
2023/10/29 18:08:59 [debug] 29#29: *6 s:0 in:'6C:l'
2023/10/29 18:08:59 [debug] 29#29: *6 s:0 in:'2D:-'
2023/10/29 18:08:59 [debug] 29#29: *6 s:0 in:'6B:k'
2023/10/29 18:08:59 [debug] 29#29: *6 s:0 in:'6E:n'
2023/10/29 18:08:59 [debug] 29#29: *6 s:0 in:'6F:o'
2023/10/29 18:08:59 [debug] 29#29: *6 s:0 in:'77:w'
2023/10/29 18:08:59 [debug] 29#29: *6 s:0 in:'6E:n'
2023/10/29 18:08:59 [debug] 29#29: *6 s:0 in:'2F:/'
2023/10/29 18:08:59 [debug] 29#29: *6 s:1 in:'6D:m'
2023/10/29 18:08:59 [debug] 29#29: *6 s:0 in:'65:e'
2023/10/29 18:08:59 [debug] 29#29: *6 s:0 in:'72:r'
2023/10/29 18:08:59 [debug] 29#29: *6 s:0 in:'63:c'
2023/10/29 18:08:59 [debug] 29#29: *6 s:0 in:'75:u'
2023/10/29 18:08:59 [debug] 29#29: *6 s:0 in:'72:r'
2023/10/29 18:08:59 [debug] 29#29: *6 s:0 in:'65:e'
2023/10/29 18:08:59 [debug] 29#29: *6 s:0 in:'3F:?'
2023/10/29 18:08:59 [debug] 29#29: *6 http uri: "/.well-known/mercure"
2023/10/29 18:08:59 [debug] 29#29: *6 http args: "topic=test"
2023/10/29 18:08:59 [debug] 29#29: *6 http exten: ""
2023/10/29 18:08:59 [debug] 29#29: *6 posix_memalign: 000055BC9DBB8A00:4096 @16
2023/10/29 18:08:59 [debug] 29#29: *6 http process request header line
2023/10/29 18:08:59 [debug] 29#29: *6 http header: "Host: localhost:4000"
2023/10/29 18:08:59 [debug] 29#29: *6 http header: "Connection: keep-alive"
2023/10/29 18:08:59 [debug] 29#29: *6 http header: "Cache-Control: max-age=0"
2023/10/29 18:08:59 [debug] 29#29: *6 http header: "sec-ch-ua: "Chromium";v="118", "Google Chrome";v="118", "Not=A?Brand";v="99""
2023/10/29 18:08:59 [debug] 29#29: *6 http header: "sec-ch-ua-mobile: ?0"
2023/10/29 18:08:59 [debug] 29#29: *6 http header: "sec-ch-ua-platform: "Linux""
2023/10/29 18:08:59 [debug] 29#29: *6 http header: "Upgrade-Insecure-Requests: 1"
2023/10/29 18:08:59 [debug] 29#29: *6 http header: "User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36"
2023/10/29 18:08:59 [debug] 29#29: *6 http header: "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7"
2023/10/29 18:08:59 [debug] 29#29: *6 http header: "Sec-Fetch-Site: none"
2023/10/29 18:08:59 [debug] 29#29: *6 http header: "Sec-Fetch-Mode: navigate"
2023/10/29 18:08:59 [debug] 29#29: *6 http header: "Sec-Fetch-User: ?1"
2023/10/29 18:08:59 [debug] 29#29: *6 http header: "Sec-Fetch-Dest: document"
2023/10/29 18:08:59 [debug] 29#29: *6 http header: "Accept-Encoding: gzip, deflate, br"
2023/10/29 18:08:59 [debug] 29#29: *6 http header: "Accept-Language: en-US,en;q=0.9"
2023/10/29 18:08:59 [debug] 29#29: *6 http header done
2023/10/29 18:08:59 [debug] 29#29: *6 event timer del: 19: 130773327
2023/10/29 18:08:59 [debug] 29#29: *6 generic phase: 0
2023/10/29 18:08:59 [debug] 29#29: *6 rewrite phase: 1
2023/10/29 18:08:59 [debug] 29#29: *6 test location: "/"
2023/10/29 18:08:59 [debug] 29#29: *6 using configuration "/"
2023/10/29 18:08:59 [debug] 29#29: *6 http cl:-1 max:1048576
2023/10/29 18:08:59 [debug] 29#29: *6 rewrite phase: 3
2023/10/29 18:08:59 [debug] 29#29: *6 http script var
2023/10/29 18:08:59 [debug] 29#29: *6 http script var: "GET"
2023/10/29 18:08:59 [debug] 29#29: *6 http script regex: "(GET|POST)"
2023/10/29 18:08:59 [notice] 29#29: *6 "(GET|POST)" matches "GET", client: 192.168.0.1, server: _, request: "GET /.well-known/mercure?topic=test HTTP/1.1", host: "localhost:4000"
2023/10/29 18:08:59 [debug] 29#29: *6 http script if
2023/10/29 18:08:59 [debug] 29#29: *6 http script var
2023/10/29 18:08:59 [debug] 29#29: *6 http script var: "GET"
2023/10/29 18:08:59 [debug] 29#29: *6 http script value: "OPTIONS"
2023/10/29 18:08:59 [debug] 29#29: *6 http script equal
2023/10/29 18:08:59 [debug] 29#29: *6 http script equal: no
2023/10/29 18:08:59 [debug] 29#29: *6 http script if
2023/10/29 18:08:59 [debug] 29#29: *6 http script if: false
2023/10/29 18:08:59 [debug] 29#29: *6 post rewrite phase: 4
2023/10/29 18:08:59 [debug] 29#29: *6 generic phase: 5
2023/10/29 18:08:59 [debug] 29#29: *6 generic phase: 6
2023/10/29 18:08:59 [debug] 29#29: *6 generic phase: 7
2023/10/29 18:08:59 [debug] 29#29: *6 access phase: 8
2023/10/29 18:08:59 [debug] 29#29: *6 access phase: 9
2023/10/29 18:08:59 [debug] 29#29: *6 access phase: 10
2023/10/29 18:08:59 [debug] 29#29: *6 post access phase: 11
2023/10/29 18:08:59 [debug] 29#29: *6 generic phase: 12
2023/10/29 18:08:59 [debug] 29#29: *6 generic phase: 13
2023/10/29 18:08:59 [debug] 29#29: *6 http init upstream, client timer: 0
2023/10/29 18:08:59 [debug] 29#29: *6 epoll add event: fd:19 op:3 ev:80002005
2023/10/29 18:08:59 [debug] 29#29: *6 http script copy: "X-Forwarded-For"
2023/10/29 18:08:59 [debug] 29#29: *6 http script var: "192.168.0.1"
2023/10/29 18:08:59 [debug] 29#29: *6 http script copy: "X-Forwarded-Host"
2023/10/29 18:08:59 [debug] 29#29: *6 http script var: "localhost"
2023/10/29 18:08:59 [debug] 29#29: *6 http script copy: "X-Forwarded-Proto"
2023/10/29 18:08:59 [debug] 29#29: *6 http script var: "http"
2023/10/29 18:08:59 [debug] 29#29: *6 http script copy: "Host"
2023/10/29 18:08:59 [debug] 29#29: *6 http script var: "freddie"
2023/10/29 18:08:59 [debug] 29#29: *6 http script copy: ""
2023/10/29 18:08:59 [debug] 29#29: *6 http script copy: ""
2023/10/29 18:08:59 [debug] 29#29: *6 http proxy header: "Cache-Control: max-age=0"
2023/10/29 18:08:59 [debug] 29#29: *6 http proxy header: "sec-ch-ua: "Chromium";v="118", "Google Chrome";v="118", "Not=A?Brand";v="99""
2023/10/29 18:08:59 [debug] 29#29: *6 http proxy header: "sec-ch-ua-mobile: ?0"
2023/10/29 18:08:59 [debug] 29#29: *6 http proxy header: "sec-ch-ua-platform: "Linux""
2023/10/29 18:08:59 [debug] 29#29: *6 http proxy header: "Upgrade-Insecure-Requests: 1"
2023/10/29 18:08:59 [debug] 29#29: *6 http proxy header: "User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36"
2023/10/29 18:08:59 [debug] 29#29: *6 http proxy header: "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7"
2023/10/29 18:08:59 [debug] 29#29: *6 http proxy header: "Sec-Fetch-Site: none"
2023/10/29 18:08:59 [debug] 29#29: *6 http proxy header: "Sec-Fetch-Mode: navigate"
2023/10/29 18:08:59 [debug] 29#29: *6 http proxy header: "Sec-Fetch-User: ?1"
2023/10/29 18:08:59 [debug] 29#29: *6 http proxy header: "Sec-Fetch-Dest: document"
2023/10/29 18:08:59 [debug] 29#29: *6 http proxy header: "Accept-Encoding: gzip, deflate, br"
2023/10/29 18:08:59 [debug] 29#29: *6 http proxy header: "Accept-Language: en-US,en;q=0.9"
2023/10/29 18:08:59 [debug] 29#29: *6 http proxy header:
"GET /.well-known/mercure?topic=test HTTP/1.1
X-Forwarded-For: 192.168.0.1
X-Forwarded-Host: localhost
X-Forwarded-Proto: http
Host: freddie
Cache-Control: max-age=0
sec-ch-ua: "Chromium";v="118", "Google Chrome";v="118", "Not=A?Brand";v="99"
sec-ch-ua-mobile: ?0
sec-ch-ua-platform: "Linux"
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Sec-Fetch-Site: none
Sec-Fetch-Mode: navigate
Sec-Fetch-User: ?1
Sec-Fetch-Dest: document
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9

"
2023/10/29 18:08:59 [debug] 29#29: *6 http cleanup add: 000055BC9DBCB850
2023/10/29 18:08:59 [debug] 29#29: *6 get rr peer, try: 1
2023/10/29 18:08:59 [debug] 29#29: *6 stream socket 20
2023/10/29 18:08:59 [debug] 29#29: *6 epoll add connection: fd:20 ev:80002005
2023/10/29 18:08:59 [debug] 29#29: *6 connect to 127.0.0.1:4001, fd:20 #7
2023/10/29 18:08:59 [debug] 29#29: *6 http upstream connect: -2
2023/10/29 18:08:59 [debug] 29#29: *6 posix_memalign: 000055BC9DB54E60:128 @16
2023/10/29 18:08:59 [debug] 29#29: *6 event timer add: 20: 60000:130773327
2023/10/29 18:08:59 [debug] 29#29: *6 http finalize request: -4, "/.well-known/mercure?topic=test" a:1, c:2
2023/10/29 18:08:59 [debug] 29#29: *6 http request count:2 blk:0
2023/10/29 18:08:59 [debug] 29#29: *6 http run request: "/.well-known/mercure?topic=test"
2023/10/29 18:08:59 [debug] 29#29: *6 http upstream check client, write event:1, "/.well-known/mercure"
2023/10/29 18:08:59 [debug] 29#29: *6 http upstream request: "/.well-known/mercure?topic=test"
2023/10/29 18:08:59 [debug] 29#29: *6 http upstream send request handler
2023/10/29 18:08:59 [debug] 29#29: *6 http upstream send request
2023/10/29 18:08:59 [debug] 29#29: *6 http upstream send request body
2023/10/29 18:08:59 [debug] 29#29: *6 chain writer buf fl:1 s:755
2023/10/29 18:08:59 [debug] 29#29: *6 chain writer in: 000055BC9DBB9818
2023/10/29 18:08:59 [debug] 29#29: *6 writev: 755 of 755
2023/10/29 18:08:59 [debug] 29#29: *6 chain writer out: 0000000000000000
2023/10/29 18:08:59 [debug] 29#29: *6 event timer del: 20: 130773327
2023/10/29 18:08:59 [debug] 29#29: *6 event timer add: 20: 86400000:217113327
2023/10/29 18:08:59 [debug] 29#29: accept on 0.0.0.0:4000, ready: 0
2023/10/29 18:08:59 [debug] 29#29: posix_memalign: 000055BC9DBA0140:512 @16
2023/10/29 18:08:59 [debug] 29#29: *8 accept: 192.168.0.1:57466 fd:21
2023/10/29 18:08:59 [debug] 29#29: *8 event timer add: 21: 60000:130773327
2023/10/29 18:08:59 [debug] 29#29: *8 reusable connection: 1
2023/10/29 18:08:59 [debug] 29#29: *8 epoll add event: fd:21 op:1 ev:80002001
2023/10/29 18:08:59 [debug] 29#29: *6 http upstream request: "/.well-known/mercure?topic=test"
2023/10/29 18:08:59 [debug] 29#29: *6 http upstream process header
2023/10/29 18:08:59 [debug] 29#29: *6 malloc: 000055BC9DB72CB0:4096
2023/10/29 18:08:59 [debug] 29#29: *6 posix_memalign: 000055BC9DB73CC0:4096 @16
2023/10/29 18:08:59 [debug] 29#29: *6 recv: eof:0, avail:-1
2023/10/29 18:08:59 [debug] 29#29: *6 recv: fd:20 137 of 4096
2023/10/29 18:08:59 [debug] 29#29: *6 http proxy status 200 "200 OK"
2023/10/29 18:08:59 [debug] 29#29: *6 http proxy header: "Content-Type: text/event-stream"
2023/10/29 18:08:59 [debug] 29#29: *6 http proxy header: "Server: ReactPHP/1"
2023/10/29 18:08:59 [debug] 29#29: *6 http proxy header: "Date: Sun, 29 Oct 2023 18:08:59 GMT"
2023/10/29 18:08:59 [debug] 29#29: *6 http proxy header: "Transfer-Encoding: chunked"
2023/10/29 18:08:59 [debug] 29#29: *6 http proxy header done
2023/10/29 18:08:59 [debug] 29#29: *6 xslt filter header
2023/10/29 18:08:59 [debug] 29#29: *6 HTTP/1.1 200 OK
Server: nginx/1.18.0 (Ubuntu)
Date: Sun, 29 Oct 2023 18:08:59 GMT
Content-Type: text/event-stream
Transfer-Encoding: chunked
Connection: keep-alive
Access-Control-Allow-Origin: *

2023/10/29 18:08:59 [debug] 29#29: *6 write new buf t:1 f:0 000055BC9DB73E08, pos 000055BC9DB73E08, size: 204 file: 0, size: 0
2023/10/29 18:08:59 [debug] 29#29: *6 http write filter: l:0 f:0 s:204
2023/10/29 18:08:59 [debug] 29#29: *6 http cacheable: 0
2023/10/29 18:08:59 [debug] 29#29: *6 http proxy filter init s:200 h:0 c:1 l:-1
2023/10/29 18:08:59 [debug] 29#29: *6 http upstream process upstream
2023/10/29 18:08:59 [debug] 29#29: *6 pipe read upstream: 0
2023/10/29 18:08:59 [debug] 29#29: *6 pipe preread: 0
2023/10/29 18:08:59 [debug] 29#29: *6 pipe buf free s:0 t:1 f:0 000055BC9DB72CB0, pos 000055BC9DB72D39, size: 0 file: 0, size: 0
2023/10/29 18:08:59 [debug] 29#29: *6 pipe length: 3
2023/10/29 18:08:59 [debug] 29#29: *6 event timer: 20, old: 217113327, new: 217113327
2023/10/29 18:08:59 [debug] 29#29: *6 http upstream request: "/.well-known/mercure?topic=test"
2023/10/29 18:08:59 [debug] 29#29: *6 http upstream dummy handler

Can you help me to solve this error?

Thank you.
Igor.

@igordeveloper igordeveloper changed the title Nginx upstream reverse proxy pending reqquest subscriber Nginx upstream reverse proxy pending request Oct 29, 2023
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

1 participant