/ / Proxy-Fehler 502, Ausführen von node js app auf dem Server apache2 - javascript, node.js, apache, proxy, ubuntu-14.04

Proxy-Fehler 502, führen Knoten js App auf Apache2 Server - Javascript, node.js, Apache, Proxy, Ubuntu-14.04

Ich versuche, eine Node.js-App auf einem Apache-Server-Überwachungsport 80 auszuführen Hier ist meine Virtualhost-Datei:

    <VirtualHost *:80>

ServerName mikus

ServerAdmin webmaster@localhost
DocumentRoot /var/www/html

ProxyPreserveHost On

ProxyPass /node http://localhost:8000/
ProxyPassReverse /node  http://localhost:8000/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>

Hier ist meine app.js-Datei:

var express = require("express");
var app = express();


app.get("/node", function(req, res) {
res.setHeader("Content-Type", "text/plain");
res.end("Welcome apache");
});

app.listen(8000, "localhost");

Und wenn ich versuche, die App zu starten"localhost / node" oder ip_adress / node, Ich habe einen 502-Proxy-Fehler: Der Proxy-Server hat eine ungültige Antwort von einem Upstream-Server erhalten. Der Proxy-Server konnte die Anforderung GET / Node nicht verarbeiten.

Grund: Fehler beim DNS-Lookup für: localhost

Apache / 2.4.7 (Ubuntu) -Server bei 127.0.0.1 Port 80.

Vielen Dank.

Antworten:

0 für die Antwort № 1

Proxy aktivieren in app.js:

app.enable("trust proxy");

Und korrigieren Sie den URI für die gültige Route in node.js:

ProxyPass /node http://localhost:8000/node
ProxyPassReverse /node  http://localhost:8000/node

0 für die Antwort № 2

localhost kann eine IPv6-Adresse sein, versuchen Sie es mit 127.0.0.1