OPNsense
  • Home
  • Help
  • Search
  • Login
  • Register

  • OPNsense Forum »
  • English Forums »
  • Web Proxy Filtering and Caching (Moderator: fabian) »
  • Nginx proxy - grPC possible?
« previous next »
  • Print
Pages: [1]

Author Topic: Nginx proxy - grPC possible?  (Read 2401 times)

andre2000

  • Newbie
  • *
  • Posts: 31
  • Karma: 2
    • View Profile
Nginx proxy - grPC possible?
« on: March 20, 2024, 08:26:21 pm »
Hi,

I would like to reverse proxy my local Netbird installation. I cannot find an option to forward grPC, which is supported in nginx since 1.13 (OPNsense has 1.24)

How do I do stuff like grpc_set_header? Template for reference:

Code: [Select]
upstream dashboard {
    # insert the http port of your dashboard container here
    server 127.0.0.1:8011;

    # Improve performance by keeping some connections alive.
    keepalive 10;
}
upstream signal {
    # insert the grpc port of your signal container here
    server 127.0.0.1:10000;
}
upstream management {
    # insert the grpc+http port of your signal container here
    server 127.0.0.1:8012;
}

server {
    # HTTP server config
    listen 80;
    server_name _;

    # 301 redirect to HTTPS
    location / {
            return 301 https://$host$request_uri;
    }
}
server {
    # HTTPS server config
    listen 443 ssl http2;
    server_name _;

    # This is necessary so that grpc connections do not get closed early
    # see https://stackoverflow.com/a/67805465
    client_header_timeout 1d;
    client_body_timeout 1d;

    proxy_set_header        X-Real-IP $remote_addr;
    proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header        X-Scheme $scheme;
    proxy_set_header        X-Forwarded-Proto https;
    proxy_set_header        X-Forwarded-Host $host;
    grpc_set_header         X-Forwarded-For $proxy_add_x_forwarded_for;

    # Proxy dashboard
    location / {
        proxy_pass http://dashboard;
    }
    # Proxy Signal
    location /signalexchange.SignalExchange/ {
        grpc_pass grpc://signal;
        #grpc_ssl_verify off;
        grpc_read_timeout 1d;
        grpc_send_timeout 1d;
        grpc_socket_keepalive on;
    }
    # Proxy Management http endpoint
    location /api {
        proxy_pass http://management;
    }
    # Proxy Management grpc endpoint
    location /management.ManagementService/ {
        grpc_pass grpc://management;
        #grpc_ssl_verify off;
        grpc_read_timeout 1d;
        grpc_send_timeout 1d;
        grpc_socket_keepalive on;
    }

    ssl_certificate /etc/ssl/certs/ssl-cert-snakeoil.pem;
    ssl_certificate_key /etc/ssl/certs/ssl-cert-snakeoil.pem;
}

Thank you!
Logged

Fright

  • Hero Member
  • *****
  • Posts: 1777
  • Karma: 164
    • View Profile
Re: Nginx proxy - grPC possible?
« Reply #1 on: March 21, 2024, 08:06:15 pm »
Hi
sorry, not yet possible via gui. i think you can try to create "empty" (specify URL Pattern only) Location in gui (and then add it to Server locations list). then add necessary grpc_* directives to location via _post-hook. directing grpc_pass to existing Upstream. Not tested but should work imo.
Logged

muchacha_grande

  • Full Member
  • ***
  • Posts: 219
  • Karma: 19
    • View Profile
Re: Nginx proxy - grPC possible?
« Reply #2 on: April 30, 2024, 08:03:56 pm »
Oh, I was investigating how to setup Netbird and found the same problem.
Logged

gradlon

  • Newbie
  • *
  • Posts: 4
  • Karma: 0
    • View Profile
Re: Nginx proxy - grPC possible?
« Reply #3 on: August 25, 2024, 10:19:45 pm »
Is this feature planed?
Logged

  • Print
Pages: [1]
« previous next »
  • OPNsense Forum »
  • English Forums »
  • Web Proxy Filtering and Caching (Moderator: fabian) »
  • Nginx proxy - grPC possible?
 

OPNsense is an OSS project © Deciso B.V. 2015 - 2024 All rights reserved
  • SMF 2.0.19 | SMF © 2021, Simple Machines
    Privacy Policy
    | XHTML | RSS | WAP2