What I'd really like to be able to do is run Node, and Apache (or maybe nginx) on the same Raspberry Pi (running Debian for Pi).

In the way that apache can set up vhosts for multiple sites on the same IP, and determine which one to load by looking at what domain was requested, I'd like to do the same somehow with multiple different servers.

Would it be possible to run some sort of proxy on port 80, and run apache/node/others on other ports and route particular domain requests through to them?

1 Answer 1


Nginx is very good at that. For instance:

server {
    listen 80;
    server_name www.example.com

    location / {
      proxy_set_header X-Real-IP  $remote_addr;
      proxy_set_header X-Forwarded-For $remote_addr;
      proxy_set_header Host $host;
      proxy_read_timeout 4m;

    location ~ /\.ht {
      deny all;

    access_log /var/log/nginx/foobar/access.log;

    client_max_body_size 25m;

You can also add something like this (to offload the underlying apache by having nginx serve the images):

location ~ /media/(.*)$ {
      alias /var/www/foobar/media/$1;
      expires 7d;
  • So, you're saying I could get nginx to listen on port 80 for requests on a certain domain, and then bounce that over to Node which is listening on another port, and serve its response out through nginx?
    – Tom Busby
    Jul 9, 2014 at 11:58
  • @TomBusby exactly :)
    – Halfgaar
    Jul 9, 2014 at 12:10
  • Awesome, that was a lot easier than I was expecting. Have a tick ;)
    – Tom Busby
    Jul 9, 2014 at 12:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.