|
| 1 | +events { |
| 2 | + worker_connections 1024; |
| 3 | +} |
| 4 | + |
| 5 | +http { |
| 6 | + # Redirect all incoming grpc-web requests to the LiT proxy. Everything else |
| 7 | + # goes directly to the internal lnd container. We use a temporary variable |
| 8 | + # here so we can rewrite it to the actual host again in the next map |
| 9 | + # directive. |
| 10 | + map $content_type $tmp_backend { |
| 11 | + "application/grpc-web+proto" "172.17.0.1:8443"; # LiT proxy. |
| 12 | + default "localhost:10009"; # main LND |
| 13 | + } |
| 14 | + |
| 15 | + # Streaming grpc-web requests can be identified by the |
| 16 | + # "Sec-WebSocket-Protocol: grpc-websockets" header field. So those requests |
| 17 | + # also need to go to the LiT proxy. |
| 18 | + map $http_sec_websocket_protocol $lnd_backend { |
| 19 | + "grpc-websockets" "172.17.0.1:8443"; # LiT proxy. |
| 20 | + default $tmp_backend; # Fall back to the value from the above map result. |
| 21 | + } |
| 22 | + |
| 23 | + # Make sure WebSockets are properly upgraded. |
| 24 | + map $http_sec_websocket_protocol $lnd_connection { |
| 25 | + "grpc-websockets" "upgrade"; |
| 26 | + default $http_connection; |
| 27 | + } |
| 28 | + |
| 29 | + server { |
| 30 | + listen 80; |
| 31 | + server_name localhost; |
| 32 | + |
| 33 | + proxy_set_header Upgrade $http_upgrade; |
| 34 | + proxy_set_header Origin https://$lnd_backend; |
| 35 | + proxy_set_header Connection $lnd_connection; |
| 36 | + |
| 37 | + location /lit { |
| 38 | + # This needs a slash at the end! |
| 39 | + proxy_pass https://172.17.0.1:8443/; |
| 40 | + } |
| 41 | + |
| 42 | + location ~* ^/lnrpc.Lightning/ { |
| 43 | + # This cannot have a slash at the end! |
| 44 | + proxy_pass https://$lnd_backend; |
| 45 | + } |
| 46 | + |
| 47 | + location ~* ^/looprpc.SwapClient/ { |
| 48 | + # This cannot have a slash at the end! |
| 49 | + proxy_pass https://$lnd_backend; |
| 50 | + } |
| 51 | + |
| 52 | + location ~* ^/poolrpc.Trader/ { |
| 53 | + # This cannot have a slash at the end! |
| 54 | + proxy_pass https://$lnd_backend; |
| 55 | + } |
| 56 | + } |
| 57 | +} |
0 commit comments