Following this example, I am running a node
application that I copied from here:
I have set up Apache 2.
for VirtualHost
, and as show below, I am proxying
an internet address to the local node
application running locally.
<VirtualHost *:80>
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:3000/
ProxyPassReverse / http://127.0.0.1:3000/
ErrorLog /var/log/httpd/hellomvc-error.log
CustomLog /var/log/httpd/hellomvc-access.log common
LogLevel debug
ServerSignature Off
</VirtualHost>
Using Postman
, When I try to POST
to the internet site like this:
http://xxx.xxx.xxx.xxx/api/auth/register/[x-www-form-url-encoded parameters here]
I get error:
Proxy Error
The proxy server received an invalid response from an upstream server.
The proxy server could not handle the request POST /api/auth/register.
Reason: Error reading from remote server
Do I also have to do a rewrite on /api/auth/register/
and pass the parameters to it in the <VirtualHost *:80>
section above? In the spirit of something like this?
RewriteEngine On
RewriteCond %{SERVER_NAME} !^www\.mydomain\.fi
RewriteRule /(.*) http://www.mydomain.fi/$1 [redirect=301L]
EDIT 1
I tried
curl -d "name=Ivan&email=idf@xxxx.com&password=secret" -X POST http://localhost:5000/api/auth/register
After a long time it comes back with:
curl: (52) Empty reply from server
Same thing with
curl -d "name=Ivan&email=idf@xxxcom&password=secret" -H "Content-Type: application/x-www-form-urlencoded" -X POST http://localhost:5000/api/auth/register
EDIT 2
This gets a response back, albeit an error. Progress!
curl -d "name=Ivan&email=idf@xxx.com&password=secret" -H "Content-Type: application/x-www-form-url-encoded" -X POST http://localhost:5000/api/auth/register
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Error: Illegal arguments: undefined, string<br> at Error (native)<br> at Object.bcrypt.hashSync (/var/www/securing-restful-apis-with-jwt/node_modules/bcryptjs/dist/bcrypt.js:189:19)<br> at /var/www/securing-restful-apis-with-jwt/auth/AuthController.js:46:31<br> at Layer.handle [as handle_request] (/var/www/securing-restful-apis-with-jwt/node_modules/express/lib/router/layer.js:95:5)<br> at next (/var/www/securing-restful-apis-with-jwt/node_modules/express/lib/router/route.js:137:13)<br> at Route.dispatch (/var/www/securing-restful-apis-with-jwt/node_modules/express/lib/router/route.js:112:3)<br> at Layer.handle [as handle_request] (/var/www/securing-restful-apis-with-jwt/node_modules/express/lib/router/layer.js:95:5)<br> at /var/www/securing-restful-apis-with-jwt/node_modules/express/lib/router/index.js:281:22<br> at Function.process_params (/var/www/securing-restful-apis-with-jwt/node_modules/express/lib/router/index.js:335:12)<br> at next (/var/www/securing-restful-apis-with-jwt/node_modules/express/lib/router/index.js:275:10)<br> at jsonParser (/var/www/securing-restful-apis-with-jwt/node_modules/body-parser/lib/types/json.js:118:7)<br> at Layer.handle [as handle_request] (/var/www/securing-restful-apis-with-jwt/node_modules/express/lib/router/layer.js:95:5)<br> at trim_prefix (/var/www/securing-restful-apis-with-jwt/node_modules/express/lib/router/index.js:317:13)<br> at /var/www/securing-restful-apis-with-jwt/node_modules/express/lib/router/index.js:284:7<br> at Function.process_params (/var/www/securing-restful-apis-with-jwt/node_modules/express/lib/router/index.js:335:12)<br> at next (/var/www/securing-restful-apis-with-jwt/node_modules/express/lib/router/index.js:275:10)</pre>
</body>
</html>