Skip to content

PagePark routing requests between apps on the same server #17

Closed

Description

@scripting

The problem

Longstanding problem with PagePark, my homebrew web server.

  • Suppose two apps are running on the same machine where PP is the http server.

  • Say one app is on the domain hello.com and the other is goodbye.com.

  • Suppose the first makes a request of the second.

    http://goodbye.com/index.html

  • It will get a connection refused.

  • Make the request from another server and it works fine.

Where to look

This is where PP maps requests to domains it's serving.

BTW, it uses request, yes I know it has been deprecated.

The pipe stuff in delegateRequest is like a black box to me, I don't really understand the magic it's doing or if it's really necessary. It probably isn't, but I wrote this code a long time ago, when I wasn't as skilled in Node.

Any help much appreciated. :-)

Activity

  1. tamaker commented on Feb 4, 2021

    @tamaker

    Please disregard if this is off base, not considering all the details you've shared or is something so basic that you've already ruled it out...

    The host machine may need to have ports 1339 and 1340 open (on my Ubuntu dev server, for example, for Node.js development, when I'm ready to test from another machine on my network, I have to use UFW to specifically OPEN the custom ports I'm using.

    And I think I saw a reference to port 80 in the code as well, so nothing else can be running on that port also.

    That would be my starting point at least. Next I would look to see if I can identify any networking related issues that may come into play -- same ip range? same VLAN?

    Good luck!

  2. mcenirm commented on Feb 5, 2021

    @mcenirm

    I think this is related to scripting/Scripting-News#110 where the PREROUTING to map 80 to the pagepark listener is never even seen by connections that originate from the same host. That is, processes on that server try to connect to port 80, and get blocked because nothing is listening there. You can diagnose this by opening a terminal and using sudo nc -k -l -v 80 < /dev/null to see what clients connects to port 80 locally, and then trying the relevant cross-site requests.

    Update: https://grainier.net/iptables-nat-prerouting-not-work-localhost/ has a reasonably concise explanation of the PREROUTING issue with localhost:

    This happens because PREROUTING isn’t used by the loopback interface. Therefore, you have to add an OUTPUT rule along with the PREROUTING rule.

    iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 9191
    iptables -t nat -A OUTPUT -p tcp -o lo --dport 80 -j REDIRECT --to-ports 9191
    

    (You'd need to replace "9191" with the actual listener port in both entries.)

  3. scotthansonde commented on Feb 5, 2021

    @scotthansonde

    I was about to point to a ServerFault entry about OUTPUT rules for localhost, but @mcenirm beat me by 30 seconds. 😄 Here it is anyway: https://serverfault.com/questions/211536/iptables-port-redirect-not-working-for-localhost

  4. scripting commented on Feb 5, 2021

    @scripting
    OwnerAuthor

    Thanks to all esp @mcenirm. That was the problem. Whew. Glad I asked.

    I posted this note in my development diary.

    image

  5. scripting commented on Feb 5, 2021

    @scripting
    OwnerAuthor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions