Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9069035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T17:19:31+00:00 2026-06-16T17:19:31+00:00

I have a particular URI scheme that is causing me some trouble. I need

  • 0

I have a particular URI scheme that is causing me some trouble. I need to run nodejs to serve the following:

domain.com
var.domain.com
var.domain.com/foo/

I have this working no problem using express.vhost() to serve up the sub domains.
However, I need serve static content and php once the URI resembles the following:

var.domain.com/foo/bar
var.domain.com/foo/bar/index.php

Here, /bar/ is some directory on my server. Everything from that url down (say /bar/images/favicon.ico) would serve like your typical directory scheme. Normally I would do the typical proxy_pass to node running on some port, but as you can see here, I need nodejs to be the primary handler on port 80, and have it pass the request off to nginx running on some other port (Or would it be possible/simpler the other way around?).

Is this type of scheme possible with a (nginx/php) / nodejs configuration?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T17:19:33+00:00Added an answer on June 16, 2026 at 5:19 pm

    Nginx allows very flexible request routing.
    I will show you a way to set up

    • a default route passed to a node.js backend
    • another route passed to a php-fpm backend
    • alternative route passed to a typical apache + mod_php backend
    • got js, images, css and other files on the nginx machine? serve them the fastest way directly from nginx

    I like, and I think that’s the default setup layout for most distros, to have conf.d and vhosts.d directories with active and available folders. So I can easily disable a vhost or configuration file by simply deleting the symlink.

    /etc
         nginx.conf
         vhosts.d/
              active
              available
         conf.d/
              active
              available
    

    /etc/nginx.conf

    # should be 1 per CPU core    
    worker_processes        2;                         
    
    error_log               /var/log/nginx/error.log;
    
    # I have this off because in our case traffic is not monitored with nginx and I don't want disks to be flooded with google bot requests :)
    access_log              off;
    pid                     /var/run/nginx.pid;
    
    events {
            # max clients = worker_processes * worker_connections
            worker_connections      1024;
            # depends on your architecture, see http://wiki.nginx.org/EventsModule#use
            use                     epoll;
    }
    
    http {
    
            client_max_body_size    15m;
    
            include                 mime.types;
            default_type            text/html;
            sendfile                on;
            keepalive_timeout       15;
    
            # enable gzip compression
            gzip                    on;
            gzip_comp_level         6;
            gzip_types              text/plain text/css text/xml application/x-javascript application/atom+xml application/rss+xml application/json;
            gzip_http_version       1.0;
    
    
            # Include conf.d files
            include conf.d/active/*.conf;
    
            # include vhost.d files
            include vhosts.d/active/*.conf;
    }
    

    /etc/nginx/vhosts.d/available/default.conf

    Say our document root for static files is /srv/www/vhosts/static/htdocs

    server {
        server_name _;
        listen      80;
    
        root        /srv/www/vhosts/static/htdocs;
    
        # if a file does not exist in the specified root and nothing else is definded, we want to serve the request via node.js
        try_files   $uri    @nodejs;          
    
        # may want to specify some additional configuration for static files
        location ~ \.(js|css|png|gif|jpg)
        {
             expires 30d;
        }
    
        location @nodejs
        {
             # say node.js is listening on port 1234, same host         
             proxy_pass  127.0.0.1:1234;
             break;
        }
    
        # just for fun or because this is another application, we serve a subdirectory via apache on another server, also on the other server it's not /phpmyadmin but /tools/phpMyAdmin
        location /phpmyadmin {
             rewrite /phpmyadmin(.*)$   /tools/phpMyAdmin$1;
             proxy_pass                 10.0.1.21:80;
             break;
        }
    
        # files with .php extension should be passed to the php-fpm backend, socket connection because it's on the same and we can save up the whole tcp overhead
        location ~\.php$
        {
             fastcgi_pass unix:/var/run/php-fpm.sock;
             include /etc/nginx/fastcgi_params;
             break;
        }
    }
    

    create a symlink to make the default vhost active

    ln -s /etc/nginx/vhosts.d/available/default.conf /etc/nginx/vhosts.d/active/.
    /etc/init.d/nginx restart
    

    See how simple and intuitive the nginx configuration language is? I just HAVE to love it 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some particular need to clone an element (image) and be draggable inside
I have a particular file in a git source code repository that contains production
I have a particular application that needs to calculate something very specific, and while
I have a particular web application that like most others, has to account for
I have a particular method that is occasionally crashing with an ArgumentException: Destination array
I have one particular FLA that is crashing every time I try to compile
I have a database client application. Some people will run multiple instances (i.e. processes)
I'm having a tough time debugging this particular error. I have the following in
In particular, the case I have in mind is this: @@RenderComponentPresentation(Component, <vbs-legacy-ct-tcm-uri>)@@ The problem
I have an HttpModule that is doing some processing on a request before the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.