Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk10 min

How to Run Nginx and Apache Together for Node.js and phpMyAdmin

Put NGINX on ports 80 and 443, move Apache to a private port, run Node.js on another private listener, and route both applications safely with tested reverse-proxy configurations.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Run NGINX as the only public web server on ports 80 and 443, then place Apache and Node.js on separate private ports. In a typical layout, NGINX terminates TLS and routes app.example.com to Node.js on 127.0.0.1:3000, while db.example.com routes to Apache on 127.0.0.1:8080, where PHP and phpMyAdmin run. This avoids port conflicts, keeps backend services off the Internet, and gives each application a clear health and logging boundary.

Two services cannot listen on the same IP address and port. The reliable solution is not to make NGINX and Apache share port 80, but to give one service the public socket and make the other an HTTP upstream.

As an Amazon Associate I earn from qualifying purchases.

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

The architecture that works

Think of NGINX as the edge gateway. A browser connects to NGINX, NGINX selects a server block using the hostname and forwards the request to the appropriate private listener. Apache does not need to compete with NGINX for port 80; it only serves requests that NGINX sends to it.

Internet client
      |
   NGINX :80/:443
    /          
Node.js :3000   Apache :8080
                    |
                PHP + phpMyAdmin

NGINX’s proxy_pass directive forwards HTTP requests to an upstream and returns the upstream response to the client. Apache can itself act as a reverse-proxy gateway, but in this arrangement it is primarily the PHP and phpMyAdmin backend. Node.js is a separate HTTP backend with its own process, port, logs and health checks.

#1 Best Overall
Sale
TOZO A1 Wireless Earbuds Bluetooth 5.3 Light Weight in Ear Headphones | IPX5 Waterproof,2 Mics for AI Calls,Immersive Premium Sound Bass Headset with Charging Case,32 EQ via App Black
  • [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.

Recommended hostname layout

  • app.example.com points to the Node.js application.
  • db.example.com points to Apache and phpMyAdmin.
  • NGINX owns public TCP ports 80 and 443.
  • Apache listens only on 127.0.0.1:8080 (or another unused private port).
  • Node.js listens only on 127.0.0.1:3000, unless it has a specific reason to be directly reachable.

Separate hostnames usually produce the least troublesome cookie, redirect and URL behavior. A single-hostname design is possible, but publishing phpMyAdmin below a path introduces additional rewriting and cookie-path work.

Plan ports and verify ownership first

Before changing a configuration file, find which processes currently own ports 80 and 443 and confirm that the proposed private ports are free.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo ss -ltnp
sudo ss -ltnp | grep -E ':(80|443|8080|3000)b'

After the migration, the expected result is NGINX listening on the public address for 80 and 443, Apache listening on 127.0.0.1:8080, and Node.js listening on 127.0.0.1:3000. Binding a backend to the loopback address prevents remote hosts from bypassing NGINX. Also enforce the same policy with the host firewall if a container, secondary interface or later configuration change could expose the port.

Choose an unused Apache port

The port 8080 examples below are conventional, not mandatory. Select any unused private port and use it consistently in Apache’s listener, its virtual host, NGINX’s proxy_pass, health checks and container mappings. phpMyAdmin’s setup documentation gives APACHE_PORT=8090 as an example of changing Apache’s port; the important point is that the public edge and backend do not share a socket.

Move Apache behind NGINX

Change Apache’s listener from a public address on port 80 to a loopback listener. On a conventional Apache installation, update the active ports configuration so it contains:

Listen 127.0.0.1:8080

Update the relevant virtual host to match the same address and port:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Sale
Smart Watch for Men Women Compatible with iPhone Samsung Android Phone 1.69 inch Full Touch Screen IP68 Waterproof Bluetooh Fitness Tracker Heart Rate/Sleep Monitor (Black)
  • 【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.
<VirtualHost 127.0.0.1:8080>
    ServerName db.example.com
    DocumentRoot /var/www/html

    # Keep the rest of your PHP and directory configuration here.
</VirtualHost>

Do not leave an active Listen 80 or <VirtualHost *:80> for this backend unless another intentional site requires it. Check the loaded configuration before restarting:

sudo apachectl configtest
sudo systemctl reload apache2

On systems that use the httpd service name, use the equivalent service commands. If the reload fails, inspect Apache’s error log and restore the last known-good listener before changing NGINX.

Run Node.js on its own private upstream

Configure the Node.js application to listen on 127.0.0.1:3000. The exact setting depends on the framework, but the effective result should be equivalent to:

HOST=127.0.0.1 PORT=3000

Start it with the process manager or service definition you already use. Confirm that it answers locally before involving NGINX:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -i http://127.0.0.1:3000/

A local connection failure is an application or process problem, not an NGINX problem. Check the Node.js service status, startup environment, application log and bind address first. Keep a health endpoint, if the application provides one, separate from a page that depends on a database or external API; it makes proxy troubleshooting much clearer.

Configure NGINX as the public reverse proxy

Create one NGINX server block for each public hostname. The proxy headers preserve the original host, client address, forwarding chain and scheme so applications can create correct links, redirects and logs.

Rank #3
New Bee Guitar Cable 10ft Electric Instrument Bass AMP Cord
  • [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

Node.js virtual host

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

    location / {
        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;
        proxy_pass http://127.0.0.1:3000;
    }
}

Use the same location in the HTTPS server block after TLS is enabled. If the application uses WebSockets, add the upgrade headers required by that application and test an actual WebSocket connection through the proxy; ordinary HTTP success does not prove that upgrades work.

Apache and phpMyAdmin virtual host

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

    location / {
        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;
        proxy_pass http://127.0.0.1:8080;
    }
}

Test the syntax and reload only after both upstreams respond locally:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo nginx -t
sudo systemctl reload nginx

Reload one service at a time and inspect its error log immediately. This keeps a failed change attributable to the service that was just modified.

Add HTTPS without creating a second proxy layer

Keep certificates, HTTP-to-HTTPS redirects and the public TLS handshake at NGINX unless there is a deliberate requirement to terminate TLS again at Apache. A typical deployment has an HTTP server block that redirects each hostname and an HTTPS server block that contains the corresponding proxy location.

server {
    listen 80;
    server_name app.example.com;
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl;
    server_name app.example.com;

    ssl_certificate     /path/to/fullchain.pem;
    ssl_certificate_key /path/to/privkey.pem;

    location / {
        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;
        proxy_pass http://127.0.0.1:3000;
    }
}

Repeat the TLS server block for the phpMyAdmin hostname with the Apache upstream. Ensure the application trusts the proxy’s forwarded scheme; otherwise it may generate HTTP redirects from an HTTPS request or set cookies incorrectly.

Publish phpMyAdmin through Apache

Apache can serve phpMyAdmin from its normal PHP configuration, or phpMyAdmin can run in a container whose internal web server is Apache. In either case, NGINX should be the only public entry point and should reach Apache over the private listener.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
BSIMB 15.6" Digital Family Calendar & Chore Chart, No Subscription Fees
  • 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.

Native Apache installation

Install and configure PHP and phpMyAdmin in Apache as you normally would, then verify the backend directly:

curl -I http://127.0.0.1:8080/

If phpMyAdmin is installed below a directory such as /phpmyadmin/, test that exact path locally before adding the public hostname. A local 404 identifies an Apache alias, document-root or PHP configuration issue; a public-only 404 usually indicates proxy path handling.

Containerized phpMyAdmin

The official phpMyAdmin image supports mapping a host port to its internal port 80 and supports an APACHE_PORT setting for changing the Apache listener inside the image. Map the container to a loopback host port rather than publishing it on every interface. For example, the host-side concept is:

127.0.0.1:8080:80

Use the image’s documented environment variables for the database connection and set PMA_ABSOLUTE_URI to the complete URL users actually open, including the trailing slash, for example:

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.
PMA_ABSOLUTE_URI=https://db.example.com/

The absolute URL matters when automatic detection cannot see the original scheme or host through the proxy. A wrong value can produce redirects to an internal address, broken form actions or cookies that do not persist.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Choose between hostnames and a shared path

Decision area Separate hostnames One hostname with /phpmyadmin/
Cookie and redirect reliability Usually simpler because phpMyAdmin owns a dedicated origin. More sensitive to cookie paths, trailing slashes and absolute-URL detection.
NGINX configuration One clear server block per application. Requires precise path locations and careful upstream URI handling.
TLS and certificates Each hostname must be covered by the certificate configuration. One hostname can simplify certificate coverage.
phpMyAdmin isolation Separate hostname makes access policy and logs easy to distinguish. Shared with the Node.js site’s URL space.
Troubleshooting Failures are easier to attribute to one backend. Path rewriting can make a browser error look like an Apache or application error.

Path-based example

If you deliberately use one hostname, route the application root to Node.js and the phpMyAdmin prefix to Apache. Preserve the trailing slash when redirecting the prefix, because relative links and cookie paths often depend on it.

server {
    listen 443 ssl;
    server_name example.com;

    location = /phpmyadmin {
        return 301 /phpmyadmin/;
    }

    location /phpmyadmin/ {
        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;
        proxy_pass http://127.0.0.1:8080;
    }

    location / {
        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;
        proxy_pass http://127.0.0.1:3000;
    }
}

This is not interchangeable with every Apache alias. Whether the upstream should receive /phpmyadmin/ or a stripped path depends on Apache’s document root and alias. Verify generated links, static assets, login actions and redirects rather than assuming the first page proves the mapping is correct. Set phpMyAdmin’s externally visible absolute URL to the real public path, such as https://example.com/phpmyadmin/, when automatic detection fails.

Validate the complete request path

  1. Check listeners. Run ss -ltnp and confirm only NGINX is publicly bound to 80 and 443; Apache and Node.js should be on their intended private addresses.
  2. Test Apache directly. Run curl -i http://127.0.0.1:8080/ and, for a path deployment, test the phpMyAdmin path used by Apache.
  3. Test Node.js directly. Run curl -i http://127.0.0.1:3000/ or its health endpoint.
  4. Test each public hostname. Use curl -i http://app.example.com/ and curl -i http://db.example.com/, then repeat over HTTPS.
  5. Inspect redirects. Confirm HTTP redirects to the intended HTTPS hostname and that no response points to 127.0.0.1, port 8080, port 3000 or an internal container name.
  6. Inspect forwarded headers. Review application and Apache logs for the original Host, client address, forwarding chain and HTTPS scheme.
  7. Exercise phpMyAdmin. Log in, reload the page, browse a table and perform a harmless state-changing operation. A page that loads but repeatedly asks for credentials or returns 404 after form submission still has a proxy URL, cookie or path problem.
  8. Check containers. Confirm the host-to-container port mapping and verify that PMA_ABSOLUTE_URI exactly matches the URL users open.

Troubleshoot common failures

“Address already in use” when starting Apache or NGINX

Two services are attempting to bind the same address and port. Use ss -ltnp to identify the owner, remove Apache’s public listener, and make its virtual host match 127.0.0.1:8080. Do not solve this by repeatedly restarting both services; the binding plan must be corrected.

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.

502 Bad Gateway from NGINX

  • Confirm the backend process is running.
  • Confirm the proxy_pass port and address exactly match the listener.
  • Use local curl against the backend.
  • Check NGINX’s error log for connection refusal, timeout or DNS errors.
  • For containers, verify that the host port is mapped to the container’s actual HTTP port.

Redirect loop or redirects to an internal URL

The backend is not recognizing the public scheme or host. Keep Host and X-Forwarded-Proto headers, configure the application to trust the proxy where required, and set phpMyAdmin’s absolute public URL when automatic detection is unreliable.

phpMyAdmin login keeps returning to the login page

Check that the browser receives a cookie for the public host and correct path, that HTTPS is reflected in the forwarded scheme, and that the externally visible URL includes the trailing slash. A path deployment is especially prone to a cookie path that does not cover /phpmyadmin/.

404 after submitting a phpMyAdmin form

Compare the form action and redirect URL with the public path. Apache may expect a different URI than NGINX forwards, or phpMyAdmin may be generating an internal absolute URL. Test the exact path locally and then through NGINX, preserving or stripping the prefix only when the Apache alias requires it.

Real client addresses are missing from logs

Ensure NGINX sends X-Real-IP and X-Forwarded-For, and configure the backend or application logging layer to trust those headers only from the local proxy. Never trust arbitrary forwarding headers from direct public clients.

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

Security and operational boundaries

  • Expose only NGINX’s public ports to the Internet. Keep Apache, Node.js and container backend ports loopback-only where possible.
  • Protect phpMyAdmin with strong database credentials and an additional access policy appropriate for your environment; it is an administrative interface, not a general public page.
  • Keep TLS certificates and renewal at NGINX, and verify renewal with an HTTPS request before certificates expire.
  • Rotate and monitor NGINX, Apache, Node.js and container logs separately. A 502, PHP error and application exception have different owners.
  • Reload after syntax validation rather than restarting unnecessarily. A reload lets existing connections finish while applying a valid configuration.
  • Document the port map, hostnames, container mappings and public URL values so a later change does not silently expose a backend.

What to remember

NGINX and Apache can run together cleanly when they do not compete for the same socket. Give NGINX ports 80 and 443, put Apache on a private HTTP port for PHP and phpMyAdmin, and run Node.js on a different private HTTP port. Route by hostname whenever possible, pass the original host and scheme, and test the real browser workflows—not just the first HTML response. Those choices eliminate the port conflict while preserving correct redirects, cookies, client logging and phpMyAdmin sessions.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

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

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.