Yes. One Nginx instance can serve a PHP application through PHP-FPM and reverse-proxy a Node.js application at the same time. Nginx remains the only public web server: requests for PHP go through FastCGI with fastcgi_pass, while requests for Node.js go over HTTP with proxy_pass.
Antihost offers Linux VPS plans with full root access, unlimited traffic on a 1 Gbps port and a 14-day free trial.
The reliable setup is to give the applications unambiguous routes—such as / for PHP and /app/ for Node—or separate hostnames. Keep Node.js on a local port such as 3000 or 8080, test the configuration with nginx -t, then reload Nginx.
As an Amazon Associate I earn from qualifying purchases.
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →How the two runtimes share one Nginx server
Nginx does not execute PHP and it does not run your Node.js application. It decides where each request goes and then returns the upstream response to the browser. For a PHP request, Nginx passes the script and FastCGI parameters to PHP-FPM. For a Node request, it behaves as a reverse proxy: it sends the request to the Node process, receives the response, and sends that response to the client.
Browser
|
v
Nginx :80 or :443
|-----------------------------|
| |
PHP location Node location
FastCGI HTTP reverse proxy
| |
PHP-FPM socket/TCP Node.js :3000 or :8080
This arrangement gives you one place for TLS certificates, public firewall rules, access logs, compression, request limits and routing. PHP-FPM and Node.js can remain private services that are not directly reachable from the internet.
#1 Best Overall
- [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
- [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
- [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
- [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
- [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.
Choose how requests are separated
Path split: one hostname, different URL prefixes
A path split keeps one hostname. For example, https://example.com/ can serve the PHP site while https://example.com/app/ is sent to Node.js.
- Advantages: one certificate and hostname, simple DNS, and a single public origin.
- Costs: the Node application must understand its prefix or Nginx must rewrite the prefix; location precedence needs careful handling; cookies and absolute URLs can require configuration.
Use a prefix that cannot be confused with a PHP route. The example below uses /app/ and marks it with ^~ so a later PHP regular-expression location does not capture a Node URL that happens to end in .php.
Hostname split: separate application ownership
A hostname split gives each service its own name, such as www.example.com for PHP and app.example.com for Node.js. Each hostname can have a separate Nginx server block.
- Advantages: the Node app can own the root path (
/), routing is easier to reason about, and cookies, redirects and frontend asset URLs are usually less surprising. - Costs: you need DNS records and certificates for both names, and cross-origin browser behavior may matter if the applications call each other.
Choose a path split when the applications are one user-facing site and the Node portion can live under a stable prefix. Choose hostnames when they are independent applications, have separate teams, or need unrelated URL and cookie policies.
Rank #2
- 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
- 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
- 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
- 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
- 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.
Prerequisites and service boundaries
Install and start Nginx, PHP-FPM and the Node.js application on the server. The exact package names, service names and PHP-FPM socket path vary by operating system and PHP version, so use the paths supplied by your distribution.
- A document root containing the PHP site’s public files, for example
/var/www/site/public. - A PHP-FPM pool listening on a Unix socket or TCP address.
- A Node.js server that listens on a private address such as
127.0.0.1:3000or127.0.0.1:8080. The official Node deployment example uses port8080; port choice itself is not significant. - Permissions allowing Nginx to read static files and PHP-FPM to read the PHP application’s files.
- A service or process manager for Node.js so it starts after reboot and restarts after a failure. Nginx proxies traffic but does not supervise the Node process.
Binding Node to localhost or another private interface prevents clients from bypassing Nginx. Expose the Node port publicly only when you have a deliberate reason and have separately secured it.
Build a path-based Nginx configuration
The following is a complete pattern for one hostname. Replace the server name, document root, PHP-FPM socket and application-specific front-controller behavior. The upstream belongs in the Nginx http context, while the server block normally goes in the enabled site configuration for your distribution.
http {
upstream nodejs {
server 127.0.0.1:3000;
}
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 80;
server_name example.com;
root /var/www/site/public;
index index.php index.html;
# Node.js application under /app/
location ^~ /app/ {
proxy_pass http://nodejs;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $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;
}
# Static files and the PHP application's front controller
location / {
try_files $uri $uri/ /index.php?$query_string;
}
# PHP scripts through PHP-FPM
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 socket shown is illustrative. Many installations use a versioned name such as /run/php/php8.2-fpm.sock; others use a TCP listener such as 127.0.0.1:9000. Use the listener configured in the active PHP-FPM pool rather than guessing it.
Rank #3
- [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
- [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
- [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
- [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
- [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by
What each important directive does
upstream nodejsgives the Node backend a stable name. A single server is enough; additional servers can be added later if you intentionally load-balance.proxy_pass http://nodejssends matching requests to the Node process. Because this form has no URI suffix, Nginx forwards the original URI, including/app/.proxy_set_header Host $hostpreserves the public host. The real-client and forwarding headers let the Node framework determine the originating address, protocol and host when it is configured to trust the proxy.fastcgi_passhands PHP requests to PHP-FPM. It is not interchangeable withproxy_pass; PHP-FPM speaks FastCGI, not ordinary HTTP.fastcgi_param SCRIPT_FILENAMEtells PHP-FPM which file to execute. The exact parameter include file can befastcgi_paramsor a distribution-provided equivalent.try_files $uri =404stops Nginx from passing a nonexistent script path to PHP-FPM. Keep this check unless your framework has a specific, documented reason to handle script paths differently.^~ /app/gives the Node prefix priority over regular-expression locations. Without it, a broadlocation ~ .php$can unexpectedly win for a URI under the Node prefix that ends in.php.
Decide whether Node should receive the /app/ prefix
There are two valid proxy_pass forms, and they produce different upstream URLs.
| Configuration | Request from client | URI sent to Node | Use when |
|---|---|---|---|
location ^~ /app/ { proxy_pass http://nodejs; } |
/app/orders |
/app/orders |
The Node router is configured with the /app base path. |
location ^~ /app/ { proxy_pass http://nodejs/; } |
/app/orders |
/orders |
The Node app expects to run at its own root path. |
Do not change the trailing slash casually. A mismatch here commonly causes 404 responses, broken static assets or redirect loops. Whichever form you select, configure the Node framework’s base URL, generated links and proxy trust settings to match it. Test both an HTML route and a static asset beneath the prefix.
Handle WebSockets and forwarded request information
Node.js supports WebSockets without additional Node-specific server configuration, but Nginx must pass the HTTP upgrade handshake. The proxy_http_version 1.1, Upgrade and Connection directives in the example cover that handshake. If your Node application does not use WebSockets, the same headers are generally harmless and keep the proxy ready for real-time endpoints.
Forwarded headers are metadata, not proof supplied by an arbitrary client. Configure the Node framework to trust proxy headers only from your Nginx proxy or private network. Otherwise an external client may be able to influence generated secure URLs, logged addresses or security decisions by sending its own forwarding headers.
Rank #4
- Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
- Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
- All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
- Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
- Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.
Use a hostname-based configuration instead
With separate hostnames, make the PHP and Node routes independent. A minimal Node server block looks like this:
upstream nodejs {
server 127.0.0.1:3000;
}
server {
listen 80;
server_name app.example.com;
location / {
proxy_pass http://nodejs;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $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 PHP site can use a separate server block with its own root, static-file rules and PHP-FPM location. Make sure the DNS records point both names to the Nginx server and obtain certificates covering each name before enabling HTTPS. If the applications exchange cookies or browser requests, define the required cookie scope and cross-origin policy intentionally rather than assuming two hostnames behave like one origin.
Keep Node.js alive independently of Nginx
Nginx only forwards traffic to the address in upstream nodejs. It will not launch the application, restart it after a crash or start it after a reboot. Use the operating system’s service manager or a dedicated process manager. The following systemd unit illustrates the responsibilities; adapt the user, working directory, Node binary and entry file to your installation.
[Unit]
Description=Node application
After=network.target
[Service]
Type=simple
User=nodeapp
WorkingDirectory=/srv/node-app
ExecStart=/usr/bin/node /srv/node-app/server.js
Restart=on-failure
Environment=NODE_ENV=production
[Install]
WantedBy=multi-user.target
After creating a service, enable it for boot and start it using your distribution’s service commands. Verify that it is listening on the expected private address before asking Nginx to proxy it. A process manager may also provide graceful restarts, environment management and application logs; those features are separate from Nginx routing.
Best Value
Deploy in a safe order
- Start PHP-FPM and verify its listener. Confirm the configured Unix socket exists or that the TCP port is listening. Check the PHP-FPM pool’s user and file permissions.
- Start Node.js privately. From the server, request the Node port directly, for example with
curl http://127.0.0.1:3000/. If the application is configured for the/appprefix, test that path as well. - Install the Nginx server configuration. Set the correct
root,server_name, PHP-FPM listener and Node port. Confirm that the Node prefix is more specific than the general PHP and static locations. - Validate syntax before applying it. Run
sudo nginx -t. Do not reload if the test reports an error; fix the named file and line first. - Reload rather than stop Nginx. Use the service manager’s reload operation, commonly
sudo systemctl reload nginx, so existing connections have a chance to complete. - Test each route through the public listener. Request a known PHP page, a static file, a Node HTML/API route and, if applicable, a WebSocket endpoint. Test both HTTP status and generated links.
- Review all three logs. Inspect Nginx access and error logs, the PHP-FPM log and the Node service log. A 502 from Nginx is only the symptom; the upstream log usually identifies the stopped process, refused connection or application exception.
Choose Unix sockets or TCP for PHP-FPM
| PHP-FPM transport | Best fit | Operational considerations |
|---|---|---|
| Unix socket | PHP-FPM and Nginx share the same host and filesystem namespace. | Often the normal local setup. The socket path is distribution- and PHP-version-dependent, and its ownership and mode must allow Nginx to connect. |
| TCP listener | PHP-FPM is isolated in another process namespace, virtual machine or container, or a socket is not convenient. | Use the actual configured address, such as a private host and port. Restrict the listener to trusted networks; do not expose PHP-FPM directly to the public internet. |
The choice does not change the Nginx routing model: PHP still uses fastcgi_pass. It changes only how Nginx reaches the PHP-FPM service.
Common failures and precise fixes
| Symptom | Likely cause | What to check or change |
|---|---|---|
| Node URLs return a PHP page | The Node location does not match, or a PHP/front-controller rule captures it. | Use an explicit location ^~ /app/, place it in the intended server block, and verify the requested hostname. |
| Node URLs return 404 while direct Node requests work | The proxy sent the wrong URI prefix. | Compare proxy_pass http://nodejs; with proxy_pass http://nodejs/; and configure the Node base path accordingly. |
| Nginx returns 502 for Node | Node is stopped, listening on a different port/interface, blocked by a local policy, or the upstream name is wrong. | Check the Node service status and log, test the private port with curl, and compare it with the upstream declaration. |
| Nginx returns 502 for PHP | The PHP-FPM socket or TCP address is wrong, unavailable or inaccessible. | Inspect the PHP-FPM pool configuration, confirm the listener exists, and check socket ownership and permissions. |
| PHP downloads as text or is served as a static file | The PHP regular-expression location is absent, malformed or in a different server block. |
Confirm location ~ .php$, fastcgi_pass, the FastCGI include and SCRIPT_FILENAME; then run nginx -t. |
| Every PHP request becomes a 404 | SCRIPT_FILENAME points to the wrong document root or try_files rejects the path. |
Resolve the real path of the requested script and ensure the Nginx root matches the deployed public directory. |
| WebSocket requests fail or immediately close | The upgrade handshake is not being forwarded, or the application is using the wrong public path. | Use HTTP/1.1 and the Upgrade/Connection headers, then inspect the Node log and confirm the client URL matches the configured prefix. |
| Redirects point to an internal port or use HTTP unexpectedly | The application does not know the original host or HTTPS scheme. | Forward Host and X-Forwarded-Proto, and configure the framework to trust those headers from Nginx. |
| Changes have no effect | The edited file is not enabled, Nginx was not reloaded, or another server block handled the request. | Run nginx -t, reload Nginx, inspect the active configuration, and test with the exact hostname sent by the client. |
Security and production details
Expose only the intended listener
Open the public firewall for Nginx’s HTTP and HTTPS ports, not for the private Node port or PHP-FPM socket. If Node must listen on a non-loopback interface, restrict that interface and port to the Nginx host or an internal network.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Fix the driver behind crashes, sound loss and screen glitches3Clear out junk files and repair common Windows errorsTerminate TLS at Nginx
Nginx can terminate TLS and forward the original scheme in X-Forwarded-Proto. Configure HTTP-to-HTTPS redirects, certificate renewal and secure-cookie behavior deliberately. The Node and PHP services can remain plain HTTP on the private host because the hop never leaves that controlled network; use encrypted upstream connections when the services cross an untrusted network.
Separate application permissions
Run Node and PHP-FPM as restricted service users, keep secrets out of the document root, and grant write access only to directories that genuinely need it. Nginx should be able to read public assets, but a public URL should not expose environment files, source archives or service credentials.
Set limits where they belong
Large uploads, long API calls and streaming responses may need Nginx timeout, buffering and body-size settings that match the application. Change them for the specific location instead of weakening limits globally. If a request times out, determine whether Nginx, PHP-FPM, Node or a database is the component that reached its timeout first.
Plan health and capacity
An Nginx upstream can contain multiple Node servers, and Nginx can stop sending traffic to an upstream that fails during ordinary request processing. That behavior is passive: it is not a substitute for an application health monitor, a process manager or capacity planning. Add additional upstream servers only when the application can share sessions, files and other state correctly.
Recommended Free Tools
Path split or hostname split: a practical decision
| Question | Prefer a path split when… | Prefer a hostname split when… |
|---|---|---|
| Who owns routing? | The Node app can consistently operate beneath a known prefix. | The Node app should own / and define all of its routes independently. |
| Cookies and browser requests | Both applications intentionally share one origin. | Cookie scope, security policy or deployment ownership should be separate. |
| Operations | You want one public hostname and one certificate. | Separate DNS, certificates and server blocks are acceptable. |
| Migration | You are adding a Node feature to an existing PHP site. | You are deploying two independently released applications. |
Final verification checklist
- PHP-FPM is running and its configured socket or TCP listener matches
fastcgi_pass. - Node.js is running under a service or process manager and listens only on the intended private address.
- The Node prefix or hostname has an unambiguous Nginx location.
- The PHP location includes the correct FastCGI parameters and document filename.
- The
proxy_passtrailing-slash choice matches the Node application’s base path. - Forwarded host, address and protocol headers are set, and the application trusts them only from Nginx.
- WebSocket upgrade headers are present if the Node application uses WebSockets.
sudo nginx -tsucceeds before every reload.- PHP, Node and Nginx logs have been checked after deployment.
- Firewall rules prevent direct public access to Node and PHP-FPM.
The core rule is simple: use fastcgi_pass for PHP-FPM and proxy_pass for Node.js, then make the path or hostname boundary explicit. Once those boundaries, listeners and process ownership are correct, one Nginx server can front both applications cleanly.
Quick Recap
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.




