1d4afb5ceSopenharmony_ci# raw-proxy plugin 2d4afb5ceSopenharmony_ci 3d4afb5ceSopenharmony_ci## Enabling for build 4d4afb5ceSopenharmony_ci 5d4afb5ceSopenharmony_ci``` 6d4afb5ceSopenharmony_ci$ cmake .. -DLWS_ROLE_RAW_PROXY=1 7d4afb5ceSopenharmony_ci``` 8d4afb5ceSopenharmony_ci 9d4afb5ceSopenharmony_ci## configuration pvo 10d4afb5ceSopenharmony_ci 11d4afb5ceSopenharmony_ci|pvo|value meaning| 12d4afb5ceSopenharmony_ci|---|---| 13d4afb5ceSopenharmony_ci|onward|The onward proxy destination, in the form `ipv4:addr[:port]`| 14d4afb5ceSopenharmony_ci 15d4afb5ceSopenharmony_ci## Note for vhost selection 16d4afb5ceSopenharmony_ci 17d4afb5ceSopenharmony_ciNotice that since it proxies the packets "raw", there's no SNI or Host: 18d4afb5ceSopenharmony_ciheader to resolve amongst multiple vhosts on the same listen port. So the 19d4afb5ceSopenharmony_civhost you associate with this protocol must be alone on its own port. 20d4afb5ceSopenharmony_ci 21d4afb5ceSopenharmony_ciIt's also possible to apply this or other role + protocols as a fallback after 22d4afb5ceSopenharmony_cihttp[s] processing rejected the first packet from an incoming connection. 23d4afb5ceSopenharmony_ciSee `./READMEs/README-http-fallback.md` 24d4afb5ceSopenharmony_ci 25d4afb5ceSopenharmony_ci## Note for packet size 26d4afb5ceSopenharmony_ci 27d4afb5ceSopenharmony_ciFor throughput, since often one side is localhost that can handle larger 28d4afb5ceSopenharmony_cipackets easily, you should create the context used with this plugin with 29d4afb5ceSopenharmony_ci 30d4afb5ceSopenharmony_ci``` 31d4afb5ceSopenharmony_ci info.pt_serv_buf_size = 8192; 32d4afb5ceSopenharmony_ci``` 33d4afb5ceSopenharmony_ci 34d4afb5ceSopenharmony_cilwsws already does this. 35d4afb5ceSopenharmony_ci 36d4afb5ceSopenharmony_ci## Using with C 37d4afb5ceSopenharmony_ci 38d4afb5ceSopenharmony_ciSee the minimal example `./minimal-example/raw/minimal-raw-proxy` for 39d4afb5ceSopenharmony_cia working example of a vhost that accepts connections and then 40d4afb5ceSopenharmony_ciproxies them using this plugin. The example is almost all boilerplate 41d4afb5ceSopenharmony_cifor setting up the context and the pvo. 42d4afb5ceSopenharmony_ci 43d4afb5ceSopenharmony_ci## Using with lwsws 44d4afb5ceSopenharmony_ci 45d4afb5ceSopenharmony_ciFor a usage where the plugin "owns" the whole vhost, you should enable the 46d4afb5ceSopenharmony_ciplugin protocol on the vhost as usual, and specify the "onward" pvo with: 47d4afb5ceSopenharmony_ci 48d4afb5ceSopenharmony_ci``` 49d4afb5ceSopenharmony_ci "ws-protocols": [{ 50d4afb5ceSopenharmony_ci "raw-proxy": { 51d4afb5ceSopenharmony_ci "status": "ok", 52d4afb5ceSopenharmony_ci "onward": "ipv4:remote.address.com:port" 53d4afb5ceSopenharmony_ci } 54d4afb5ceSopenharmony_ci }], 55d4afb5ceSopenharmony_ci``` 56d4afb5ceSopenharmony_ci 57d4afb5ceSopenharmony_ciand then define the vhost with: 58d4afb5ceSopenharmony_ci 59d4afb5ceSopenharmony_ci``` 60d4afb5ceSopenharmony_ci "apply-listen-accept": "1", 61d4afb5ceSopenharmony_ci "listen-accept-role": "raw-proxy", 62d4afb5ceSopenharmony_ci "listen-accept-protocol": "raw-proxy" 63d4afb5ceSopenharmony_ci``` 64d4afb5ceSopenharmony_ci 65d4afb5ceSopenharmony_ciwhich tells it to apply the role and protocol as soon as a connection is 66d4afb5ceSopenharmony_ciaccepted on the vhost. 67