sheltont

sheltont

I am working on a Phoenix web app. The incoming requests are actually redirected by IPTABLES. Right now I want to know the original destination before iptables redir the connection. For a normal tcp app with c/c++, I can call getsockopt with SO_ORIGINAL_DST.

I’m wondering if possible to get the underlying gen_tcp (through ranch_transport??) and then calling getsocketopt to it. Any advise?

Showing Posts 1 to 3

hauleth

hauleth

Even if there would be such way to do it reliably then you would hit the wall with not being able to call getsockopt on that as SO_ORIGINAL_DST is not supported by Erlang. You can try to write your own ranch_transport which would use socket module instead, but that will be tremendous task which would require quite a lot low-level understanding of BEAM. Question is whether it is feasible.

EDIT: maybe there are better solutions for what you need. You can use for example L7 proxy instead of L4, and that can add proper header to HTTP requests, or you can use socket activation to make application listen on restricted port instead of L4 proxying.

sheltont

sheltont OP

Thanks for the reply.

L7 proxy is not available in my use case. But “socket activation” sounds well for me. Let me have a try and then get back if any good news.

Thanks again.

hauleth

hauleth

You can use local Nginx/HAproxy with reverse proxy configuration to listen directly on 80/443 and then forward requests to the Phoenix application, it doesn’t need to be external service.

For socket activation with systemd you can check out my example project that shows how it can be achieved.

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews