[erlang-questions] Nitrogen on several ports

John Hughes <>
Wed Mar 14 20:46:54 CET 2012


Hi Jesse,

Thank you! That sounds like just what I need. I didn't realise wf:socket() 
would tell me the socket type--very useful!

I am actually using Apache as a reverse proxy to forward port 80 to 8000 
already... my problem is I want to access the *same page* (i.e. same .erl 
file) through http and https, and see different options in each case. I 
suppose I could make two different pages, but that would be more complex and 
less maintainable however I did it (code duplication or a more complex 
module structure). I'm not sure nginx would really solve that problem for 
me.

John

----- Original Message ----- 
From: "Jesse Gumm" <>
To: "John Hughes" <>
Cc: <>
Sent: Wednesday, March 14, 2012 5:13 PM
Subject: Re: [erlang-questions] Nitrogen on several ports


Hi John,

You can get the socket from Nitrogen and from the socket determine its type:

In code that could be something like

is_ssl() ->
   Socket = wf:socket(),
   is_tuple(Socket) andalso element(1,Socket)=:=sslsocket.

Though I personally prefer to throw nginx in front of Nitrogen deal
with that kind of routing (URL-based, anyway).

-Jesse

On Wed, Mar 14, 2012 at 9:20 AM, John Hughes <> wrote:
> I’m running nitrogen on inets, configured to serve *two* ports, an 
> ordinary
> ip port and an ssl port. That works fine—nitrogen serves the same
> information on both ports, but if I want to interact securely with the 
> site
> then I can do it on the ssl port.
>
> What I would LIKE to do is to disable the parts of the site that really
> require secure access, when I visit it through the non-encrypted port. But
> to do that, I need to find out from nitrogen which port the request being
> served came through. Does anyone know of a way to do that?
>
> John
>
> _______________________________________________
> erlang-questions mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-questions
>



-- 
Jesse Gumm
Owner, Sigma Star Systems
414.940.4866 || sigma-star.com || @jessegumm





More information about the erlang-questions mailing list