Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

Yes. One Nginx server can front PHP and Node.js at the same time. Nginx sends PHP requests to PHP-FPM with fastcgi_pass, while it reverse-proxies a separate URL path or hostname to a Node.js process with proxy_pass. Keep Node on a local or private port, make the Nginx locations unambiguous, test the configuration, and reload Nginx.

The pattern works because the two runtimes use different upstream protocols: PHP-FPM speaks FastCGI, and a Node application normally speaks HTTP. Nginx is the public entry point that can serve static files, terminate TLS, add security headers, and route each request to the appropriate backend.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How the combined setup works

A browser connects to Nginx on ports 80 or 443. Nginx examines the hostname and URI, then selects one location block:

  • PHP location: a request ending in .php is passed to PHP-FPM over a Unix socket or TCP listener. PHP-FPM executes the script and returns the response through FastCGI.
  • Node location: a request under a defined prefix such as /app/ is sent as ordinary HTTP to a Node process listening on a private port such as 3000 or 8080.
  • Static location: files such as HTML, CSS, JavaScript bundles, images, and downloads are read directly by Nginx.

For a reverse-proxied request, Nginx sends the request to the selected server, fetches its response, and sends that response back to the client. The Node process therefore does not need to be internet-facing, and both applications can share TLS certificates, access logging, compression policy, and a public IP address.

#1 Best Overall
Sale
Compressed Air Duster,130000RPM Super Power Cordless Air Duster,Rechargeable Brushless Blower,3 Gear Adjustable Blower with LED Light,Dust Remover for Computer/House/Outdoor/Car
  • Powerful Turbo Fan:CAGIWIRU Electric Air Duster have reached speed up to 130000RPM,Can efficient remove dust and debris.With LED light and Three Adjustable Speed to meet with different cleaning tasks.
  • With Attached USB C Fasting Charging cable.Charing 3 hours,Enjoy up to 240 minutes of use on the lowest setting, For third speed can use for 25mins.with four charging options to meet with your needs.
  • Wide Application:Upgraded attached 5 different nozzles,making it suitable for a variety of scenes, such as car,pet, pc, keyboards, and other electronic devices. It also serves for office and home clean duster.
  • Handy Design & Portable:Cordless air duster electric nozzle is Light weight and small size, design and comfortable to hold and space saving, convenient to carry around. You can put it in your room or inside the car without taking up space.
  • Warranty & Support: Our Electric air duster comes with 5 years warranty and 24/7 customer service. During this period, if you have any questions,pls kindly feel free to contact us.

Choose a routing design before configuring Nginx

Decide whether the applications should be separated by URL path or by hostname. Both designs are valid, but they affect URI handling, cookies, links, and deployment ownership.

Path split: one hostname

With a path split, PHP remains at the site root and Node is mounted at a prefix such as /app/:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Public URL Backend Typical use
https://example.com/index.php PHP-FPM Existing PHP site or CMS
https://example.com/app/ Node.js on port 3000 Dashboard, API, or interactive feature
https://example.com/assets/site.css Nginx filesystem Shared static assets

This keeps one origin, which can simplify same-origin browser requests. The trade-off is that the Node application must understand that it is mounted below /app/, or Nginx must rewrite the URI carefully. Relative links, client-side router bases, redirects, cookies, and WebSocket paths all need to match the prefix.

Hostname split: separate subdomains

A hostname split gives each application its own public origin, for example example.com for PHP and app.example.com for Node. Each hostname gets a separate Nginx server block and usually a separate document root or upstream.

This is generally easier when the applications have independent teams, release schedules, authentication cookies, or URL structures. The applications are cross-origin, however, so browser calls between them may require CORS, carefully scoped cookies, or an explicit API gateway policy.

How to choose

  • Choose a path split when one site should present a unified origin and the Node application can operate correctly below a prefix.
  • Choose hostnames when the applications have independent routing, cookies, deployments, or teams.
  • Do not create overlapping rules such as an unrestricted catch-all proxy and a PHP regular expression that can both claim the same request. Every public path should have one intentional owner.

Prerequisites and service layout

You need a server capable of running three long-lived services: Nginx, PHP-FPM, and the Node.js application. The exact package names and PHP-FPM socket path vary by operating system and PHP version.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • A DNS record pointing the chosen hostname or hostnames to the server.
  • Nginx installed and allowed through the host firewall on ports 80 and 443.
  • PHP-FPM installed, started, and configured with a pool that Nginx can reach.
  • Node.js installed, with the application listening on a local address and port. The official Nginx Node deployment example uses port 8080; port 3000 is also common.
  • An application directory owned and permissioned so the relevant service can read it, while writable directories are limited to those that genuinely need writes.
  • A service manager or process manager for Node. Nginx proxies traffic but does not restart a crashed Node process or start it automatically after a reboot.

Keep Node bound to 127.0.0.1 or another private interface unless there is a deliberate reason to expose it. Binding to all interfaces can make the application reachable around Nginx, bypassing TLS, authentication, rate limits, and security headers.

Install and verify each runtime

Start Nginx and PHP-FPM

On a Debian- or Ubuntu-style system, package names commonly resemble nginx and php-fpm; distributions may install a versioned PHP-FPM package instead. Use your distribution’s package manager, enable both services at boot, and start them.

Rank #2
EVEO® Screen Cleaner Spray Kit (Streak-Free) TV Screen Cleaner for Smart TV, Lcd, LEd, Oled | Computer Screen Cleaner Spray and Wipe Microfiber Cloth - TV, Monitor, Laptop, iPad, Car - 6.7oz 1 Pack
  • Screen Cleaner is Your Screen’s New Bestfriend! - EVEO is proud to present a screen cleaner that’s perfectly suited for your TV. Meet your new screen cleaner, computer screen cleaner, laptop cleaner, iPad cleaner, Macbook,tv cleaner or any other electronic device. Our screen cleaner spray and wipe along with the included plush microfiber cloth, easily removes dust, fingerprints & other smudges on the screen’s surface. Clean effectively for a streak-free screen
  • Gentle on your Screens - Our screen cleaner spray and wipes is compatible to be used even for the most sensitive LCD, LED, CRT, and OLED screens in proper use. Be at ease knowing that this product is compatible with all the major brands: LG, SONY, Samsung, Sharp, iPad, iPhone, Android screens, Kindle, PC monitors - we’ve got you covered! Can be used as LCD screen cleaner, tv cleaner, smart tv screen cleaner, and more
  • Premium Super Soft Plush Microfiber Cloth - Included in this efficient screen cleaning kit. This screen cleaner spray and wipe has our signature plush microfiber cloth specially designed to comply with screens and monitors and leave them streak-free. Has been shown to effectively absorbs stubborn stains, zero streaks, and no fiber shedding. Always use this together with our screen cleaner for the best results
  • Easy-to-Use Screen Cleaner Kit + microfiber cleaning cloth - The EVEO Screen Cleaning Kit will easily be your new favorite tool when it comes to taking care of the things you love most, quick and easy solution for a streak-free screen. Simply screw on the sprayer gun on the screen cleaner bottle. Spray the cleaning liquid onto the microfiber cloth, then wipe the screen until desired cleanliness & shine is achieved.
  • Quality Screen Care Kit Worth Purchasing - Enjoy a convenient Screen Cleaner anytime, anywhere you need it. Your satisfaction is our top priority. We stand behind the quality of our products and that’s why, you shouldn’t be worrying at all. We manufacture the Best Screen Cleaner. and can be used for laptop cleaning kit, laptop screen cleaner, tv screen cleaner for smart tv. MacBook screen cleaner, monitor cleaner or screen cleaner spray for electronic devices with microfiber cleaning cloth

Verify that Nginx is listening on the intended public ports and that PHP-FPM is running. Find the configured PHP-FPM endpoint in the pool or distribution configuration. It may be a Unix socket such as /run/php/php-fpm.sock or a versioned socket, or it may be a TCP address such as 127.0.0.1:9000. Do not copy a socket path from another distribution without checking it on this server.

Run the Node application locally

Configure the application to listen on a known port:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
HOST=127.0.0.1 PORT=3000 node server.js

The exact start command depends on the application. Confirm locally from the server before involving Nginx:

curl -i http://127.0.0.1:3000/

A successful response proves that the process is running and reachable on the selected address. It does not prove that its public base path, forwarded headers, WebSockets, or production error handling are correct.

Configure PHP-FPM in Nginx

Place the PHP rules inside the appropriate server block. This example assumes a document root of /var/www/example/public; change it to the actual directory.

server {
    listen 80;
    server_name example.com;

    root /var/www/example/public;
    index index.php index.html;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ .php$ {
        try_files $uri =404;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_pass unix:/run/php/php-fpm.sock;
    }
}

The try_files check prevents Nginx from sending a nonexistent script name to PHP-FPM. include fastcgi_params supplies standard request variables, while SCRIPT_FILENAME tells PHP-FPM which file to execute. Replace the example socket with the endpoint reported by your PHP-FPM installation. For a TCP listener, use a value such as fastcgi_pass 127.0.0.1:9000; when that is how PHP-FPM is configured.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Do not pass uploaded files, images, or arbitrary extensions to PHP-FPM. Keep the PHP expression narrow and verify that the document root cannot be used to execute files from an upload directory.

Define the Node.js upstream

An upstream groups one or more HTTP backend servers. Put the upstream in the Nginx http context, outside any server block:

Rank #3
BladeHawks RGB Gaming Mouse Pad Extra Large Extended 31.5x12 Inch-Black
  • 【Large size】:Measuring 800 x 300 mm/ 31. 5×12 inches, which is wider and taller than others. Large mouse pad can perfectly fit your keyboard and mouse of any size, and there is also ample space for peripherals such as phones, tablets, etc.
  • 【LED backlight mouse pad】:Blade Hawks RGB mouse pad provides 7 static modes and 7 dynamic modes will give you the options you are looking for. Power-off memory function remembers the last lighting mode you selected. The super glow fiber Chroma will give you a colorful gaming setup that you want.
  • 【Anti-slip rubber base】:Made from Natural rubber, this gaming mousepad will firmly grip your desktop, allowing you to enjoy the ultimate precision in the games you are most passionate about. It also comes with a texture that enhances this ability even further.
  • 【Smooth and waterproof surface】: Micro-textured cloth surface, for extremely precise mouse control and a smooth movement. When liquid splashes on the gaming mouse pad, it forms water droplets and slides down. Will not delay your work or gameplay.
  • 【Plug and play】: This mouse and keyboard pad is powered by USB, plug and play, no driver required. One button control light modes. Press one time to change the lighting mode, press twice to change the brightness, press and hold about 3 seconds turn ON/OFF.
http {
    upstream nodejs {
        server 127.0.0.1:3000;
    }

    # Other http-level settings and server blocks follow.
}

If your distribution separates configuration into files, place the upstream where that installation includes it in the http context. Adding more server lines later allows Nginx to distribute requests across multiple Node instances, but a single upstream server is enough for this one-process arrangement.

Route a path to Node.js

Add a distinct location to the same PHP site. This example keeps the /app/ prefix when proxying:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
server {
    listen 80;
    server_name example.com;

    root /var/www/example/public;
    index index.php index.html;

    location ^~ /app/ {
        proxy_pass http://nodejs;
        proxy_http_version 1.1;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ .php$ {
        try_files $uri =404;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_pass unix:/run/php/php-fpm.sock;
    }
}

The ^~ prefix makes the intended application path win over regular-expression locations. The PHP regular expression therefore does not accidentally take ownership of a Node route that happens to contain a suffix resembling .php.

Understand the trailing-slash behavior

With location ^~ /app/ and proxy_pass http://nodejs;, Nginx sends the original URI, including /app/, to Node. A request for /app/users arrives at the backend as /app/users.

If the Node application expects to receive /users instead, use a replacement URI deliberately:

location ^~ /app/ {
    proxy_pass http://nodejs/;
    proxy_http_version 1.1;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
}

The slash on the proxy_pass value changes how the matching prefix is replaced. Test both forms with a route that reports its received path, then configure the Node framework’s base path, static asset URLs, redirects, and API documentation consistently. Do not switch this slash casually after the application is live.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use a hostname for Node when a path is awkward

A separate server block avoids prefix rewriting:

server {
    listen 80;
    server_name app.example.com;

    location / {
        proxy_pass http://nodejs;
        proxy_http_version 1.1;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

Here, /dashboard remains /dashboard at Node, and the Node process can be designed as a root-mounted application. Add a DNS record for app.example.com and include both hostnames in the TLS configuration when HTTPS is enabled.

Forward headers, redirects, and WebSockets correctly

The forwarding headers in the examples preserve the original host, client address, proxy chain, and scheme. Configure the Node framework to trust the proxy only as appropriate for your network. Otherwise, code that generates absolute URLs, marks cookies as secure, applies IP-based limits, or records audit data may see Nginx’s address or believe the request was plain HTTP.

Rank #4
Sale
Vaydeer Wrist Rest for Keyboard and Mouse, Computer Ergonomic Wrist Support Pad, Soft Memory Foam Arm Cushion for Desk, Palm Hand Office Laptop Typing
  • 【Softer and More Comfortable】Vaydeer wrist rest has unique diamond pattern, which is the combination of softness and aesthetics. The materials of wrist rest are improved into higher quality memory foam and covered with silky smooth lycra. The computer wrist rest makes you as comfortable and cushiony as like rest your wrists on clouds.
  • 【Ergonomic Wrist Saver】The wrist rests for keyboard and mouse comes with a 17.32×3.15×0.83 inch keyboard wrist pad and a 5.94×3.15×0.83 inch mouse wrist support. Based on ergonomic design, the unique concave shape is the perfect fit for your wrist joints. The wrist rest pad fits most computer keyboards and laptops, improve hand and wrist posture, release your wrist and arm stress.
  • 【Non-Slip Rubber Bottom】Featuring an anti-skid silicone base on the bottom, this wrist keyboard support stays firmly in place on your desk, preventing the padding from sliding around, ensuring stable and consistent wrist support during extended computer sessions.
  • 【Better Experience & Pain Relief】Our keyboard arm rest is beneficial to alleviate the soreness caused by direct contact and friction between your arm and a hard desk surface, reducing the risk of wrist fatigue or carpal tunnel. The soft texture of memory foam can evenly distribute the pressure around your wrists and provide good support with just enough give.
  • 【Helpful in Multiple Scenarios】Whether you're working, studying, writing, typing, gaming, this keyboard and mouse rest combo is an essential accessory to add comfort and support to your hands and wrists. It’s also a great gift for men, women, family, friend, coworker, gamer, teacher, etc.

For WebSockets, use HTTP/1.1 and explicitly forward the upgrade negotiation:

location ^~ /app/ {
    proxy_pass http://nodejs;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
}

The Node.js app server supports WebSockets without additional Node-specific configuration, but the Nginx proxy must preserve the upgrade headers and the client must connect to the correct path or hostname. If ordinary HTTP works but a WebSocket immediately disconnects, inspect these headers and any intermediary timeout settings.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Keep Node alive with a service manager

Nginx is not an application supervisor. Run Node under the operating system’s service manager or a dedicated process manager so it starts after reboot, restarts after failure, receives environment variables consistently, and writes logs somewhere you can inspect.

A production service should define the working directory, a non-root user, the exact Node start command, required environment variables, restart behavior, and a dependency on the network. Test a deliberate stop and restart, then reboot or use the service manager’s status command to confirm that the application returns automatically. Avoid running a development watcher or a terminal-only process behind a production proxy.

Validate and reload safely

  1. Check the Node backend directly with curl -i http://127.0.0.1:3000/ and test a representative API or page.
  2. Check PHP-FPM’s service status and confirm that its socket or TCP listener exists and is accessible to the Nginx worker user.
  3. Run nginx -t. Do not reload if the syntax test fails; fix the reported file and line first.
  4. Reload Nginx with the service manager’s reload action. A reload applies the new workers while allowing existing connections to finish; it is preferable to stopping the server for ordinary configuration changes.
  5. Request a PHP URL, a static file, the Node prefix or hostname, a missing URL, and (if applicable) a WebSocket endpoint from an external client.
  6. Watch Nginx’s error and access logs, the PHP-FPM log, and the Node service log while making those requests.

Test through the public HTTPS name as well as with local curl. A local backend check can succeed while DNS, TLS, Host-based routing, firewall rules, or forwarded-scheme handling is wrong at the public edge.

Path split versus hostname split

Decision Path split Hostname split
Public URLs One domain, for example /app/ Separate names, for example app.example.com
Node URI handling May require a base path or prefix replacement Usually receives its natural root-relative paths
Browser origin Same origin, simpler direct browser calls Cross-origin calls may require CORS or cookie planning
Cookie scope Can use host cookies with path scoping Must deliberately scope cookies across subdomains, if needed
Deployment independence Shared host and routing rules Clearer ownership and independent server blocks
Main failure mode Incorrect prefix rewriting or asset URLs DNS, TLS, CORS, or cross-origin authentication mistakes

Unix socket or TCP for PHP-FPM?

PHP-FPM endpoint Advantages Use when
Unix socket Local, avoids a TCP port, and is commonly supplied by distributions Nginx and PHP-FPM share the host or filesystem namespace
TCP listener Works across process or container boundaries and is explicit about the network endpoint PHP-FPM is isolated in another namespace, container, or host

The exact Unix socket name and directory depend on the distribution and PHP version. Whichever endpoint you choose, verify permissions: Nginx must be able to connect, and PHP-FPM must be able to read the requested script and any required application files.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Security and operational checklist

  • Expose only Nginx publicly where possible; keep Node on localhost or a private network.
  • Terminate TLS at Nginx and redirect HTTP to HTTPS after confirming certificates and health checks.
  • Set a restrictive Node and PHP file-permission model; never make the entire application tree writable by the web user.
  • Do not expose PHP-FPM’s Unix socket or TCP listener to untrusted networks.
  • Limit upload sizes, request body sizes, and proxy timeouts to values your applications actually need.
  • Use application authentication and authorization; Nginx routing is not an identity system.
  • Preserve and rotate logs, and monitor both upstream failures and application-level errors.
  • Use separate environment variables and secrets for production, and do not place credentials in publicly served files.
  • Document whether Node expects the original /app/ prefix and whether it trusts forwarded headers.
  • When adding a second Node instance, verify session storage, WebSocket affinity requirements, and shared assets before enabling load distribution.

Troubleshooting common failures

502 Bad Gateway for Node

Check that the Node process is running, listening on the address and port in the upstream, and reachable from the Nginx host. A process bound only to a different interface, a wrong port, a crashed service, or a local firewall rule can all produce a 502. Read the Nginx error log for connection-refused or timeout details, then test the exact upstream URL with curl.

502 Bad Gateway for PHP

Verify the PHP-FPM service, the socket or TCP address in fastcgi_pass, and permissions on a Unix socket. A versioned socket path left over from an upgrade is a frequent cause. Confirm that SCRIPT_FILENAME resolves to a real file under the configured document root.

Best Value
Sale
Under Desk Cable Management Tray No Drill, Metal Mesh Cable Management Under Desk with Clamp Mount, 2 Hole Cable Tray with Wire Management and Cord Organizer for Home Office Standing Desk
  • 【No Drill Mounted】Cable management tray can be assembled in as little as 3 minutes or less-simply. Side clips easily clampe the edge of desk, pass through the holes on the sides, and secure excess cables with baskets. Desk cable management supports inward or outward installation to meet your needs in different scenarios, and provides you with great convenience when collecting and organizing wires.
  • 【Rubber Pad Protects Desk】Wire organizer under desk built-in soft rubber pads on the clamp protect your desk from scratches, so you will not damage your furniture or office.
  • 【Sturdy and Beautiful】Cord management under desk is made of high-quality carbon steel and holds about 15 lbs. The wire basket has 2 holes on each side of the tray to enable your cables to pass freely. Cable baskets are suitable for desk thickness use from 0.4" to 2.4".
  • 【Space Saving & Keep Organized】Desk cable management tray holds all your power cords, outlet strips, USB hubs and computer transformers hidden from your feet, and the data cables will not enter the vacuum cleaner to keep your desk clean and tidy. Desk wire organizer is also suitable for use in the kitchen and outdoors.
  • 【Reduce Safety Risks】Cable tray under desk keeps all plugs away from your kids, no more worry about tripping. Using 2 holes wire tray saves extra space, helps you easily cabling and wire protection. The mesh design is not easy to accumulate dust, but avoids safety accidents caused by messy wires.

Every request goes to PHP

The Node location may be missing, placed in a different server block, or losing to a broader rule. Confirm the request’s Host header selects the expected server, use an explicit prefix such as location ^~ /app/, and inspect the effective configuration after testing.

Node receives the wrong path

Compare proxy_pass http://nodejs; with proxy_pass http://nodejs/;. The trailing slash controls whether the matching prefix is retained or replaced. Align the choice with the Node framework’s base URL and test links, redirects, static assets, and API routes.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

PHP downloads instead of executing

Check that the PHP regular-expression location is active, that fastcgi_pass points to a live PHP-FPM endpoint, and that the request is reaching the intended server block. Never solve this by making the document root broadly executable; correct the location and FastCGI parameters.

WebSockets fail while HTTP works

Use HTTP/1.1 and forward Upgrade and Connection headers. Check that the client uses the same path or hostname Nginx proxies and that the Node application is not rejecting the forwarded host or scheme.

Redirects point to HTTP or the wrong host

Forward Host and X-Forwarded-Proto, then configure the Node and PHP applications to trust those headers only through the known proxy. Also check canonical-host redirects in both applications so they do not continually redirect each other.

When one server is no longer enough

The pattern is appropriate for a small or medium deployment when CPU, memory, disk, and upstream concurrency are sufficient. Separate the services onto additional hosts or containers when one workload can starve the other, when independent scaling is required, or when security boundaries demand isolation. The Nginx routing model remains the same: PHP requests use FastCGI, and Node requests use HTTP proxying; only the upstream addresses and service-management design change.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Frequently Asked Questions

Can PHP-FPM and Node.js listen on the same port?

No. Give them different endpoints. PHP-FPM normally uses a Unix socket or a dedicated FastCGI TCP listener, while Node uses an HTTP port such as 3000 or 8080. Nginx connects to each endpoint with the protocol-specific directive.

Do I need two Nginx installations?

No. A single Nginx instance can contain multiple locations and server blocks, including PHP-FPM routing and one or more Node reverse proxies.

Should I expose the Node port in the firewall?

Usually not. Allow public traffic to Nginx and bind Node to localhost or a private interface. Open the Node port only when another trusted system must connect to it directly.

Why does changing the proxy_pass trailing slash matter?

Nginx handles the matching URI prefix differently depending on whether the proxy URL ends with a slash. One form preserves a request such as /app/users; the other can replace /app/ so Node receives /users. Choose deliberately and test the backend’s received path.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Can Nginx restart my Node application after a crash?

No. Nginx only proxies requests. Use the operating-system service manager or a Node process manager for startup, restart, environment variables, and boot persistence.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.