openresty / openresty/lua-nginx-module

How to close tcp connection by lua when use OR proxy websocket?

Open
#1,856 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
11.8k
Forks
2.1k
Avg merge
6h 1m
Merged PRs (30d)
6

Description

As shown below,I used OR to proxy websocket, after switching protocol, the http request finished and websocket continued with the tcp connection. But how can I close the tcp connection actively by lua when I received a singal in anthor http request?

http {
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
upstream websocket {
server localhost:8010;
server localhost:8011;
}
server {
listen 80;
server_name localhost;
access_log /var/log/nginx/yourdomain.log;

location / {
  proxy_pass http://websocket;
  proxy_read_timeout 300s;

  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_http_version 1.1;
  proxy_set_header Upgrade $http_upgrade;
  proxy_set_header Connection $connection_upgrade;
	}
}

}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the Lua API and the WebSocket proxy behavior shown in the issue configuration, focusing on how a later HTTP request could affect an existing TCP connection. Done means identifying a supported entry point for this cross-request closure or documenting the limitation and its expected behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua, nginx
Domain
networking
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.