Apache 代理 mod_rewrite

Apache 代理 mod_rewrite

下列的例如,我正在运行node这里

Apache 2.我已经为设置了VirtualHost,如下所示,我是在本地运行的proxying本地应用程序的互联网地址node

<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>

使用Postman,当我尝试POST访问这样的互联网网站时:

http://xxx.xxx.xxx.xxx/api/auth/register/[x-www-form-url-encoded parameters here]

我收到错误:

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

我是否还必须在上面的部分中重写 /api/auth/register/并将参数传递给它<VirtualHost *:80>?本着这样的精神?

RewriteEngine On
RewriteCond %{SERVER_NAME} !^www\.mydomain\.fi
RewriteRule /(.*) http://www.mydomain.fi/$1 [redirect=301L]

编辑1

我试过

curl -d "name=Ivan&[email protected]&password=secret" -X POST http://localhost:5000/api/auth/register

过了很长时间它才返回:

curl: (52) Empty reply from server

同样的事情

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

编辑2

尽管有错误,但仍会收到响应。进步了!

curl -d "name=Ivan&[email protected]&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> &nbsp; &nbsp;at Error (native)<br> &nbsp; &nbsp;at Object.bcrypt.hashSync (/var/www/securing-restful-apis-with-jwt/node_modules/bcryptjs/dist/bcrypt.js:189:19)<br> &nbsp; &nbsp;at /var/www/securing-restful-apis-with-jwt/auth/AuthController.js:46:31<br> &nbsp; &nbsp;at Layer.handle [as handle_request] (/var/www/securing-restful-apis-with-jwt/node_modules/express/lib/router/layer.js:95:5)<br> &nbsp; &nbsp;at next (/var/www/securing-restful-apis-with-jwt/node_modules/express/lib/router/route.js:137:13)<br> &nbsp; &nbsp;at Route.dispatch (/var/www/securing-restful-apis-with-jwt/node_modules/express/lib/router/route.js:112:3)<br> &nbsp; &nbsp;at Layer.handle [as handle_request] (/var/www/securing-restful-apis-with-jwt/node_modules/express/lib/router/layer.js:95:5)<br> &nbsp; &nbsp;at /var/www/securing-restful-apis-with-jwt/node_modules/express/lib/router/index.js:281:22<br> &nbsp; &nbsp;at Function.process_params (/var/www/securing-restful-apis-with-jwt/node_modules/express/lib/router/index.js:335:12)<br> &nbsp; &nbsp;at next (/var/www/securing-restful-apis-with-jwt/node_modules/express/lib/router/index.js:275:10)<br> &nbsp; &nbsp;at jsonParser (/var/www/securing-restful-apis-with-jwt/node_modules/body-parser/lib/types/json.js:118:7)<br> &nbsp; &nbsp;at Layer.handle [as handle_request] (/var/www/securing-restful-apis-with-jwt/node_modules/express/lib/router/layer.js:95:5)<br> &nbsp; &nbsp;at trim_prefix (/var/www/securing-restful-apis-with-jwt/node_modules/express/lib/router/index.js:317:13)<br> &nbsp; &nbsp;at /var/www/securing-restful-apis-with-jwt/node_modules/express/lib/router/index.js:284:7<br> &nbsp; &nbsp;at Function.process_params (/var/www/securing-restful-apis-with-jwt/node_modules/express/lib/router/index.js:335:12)<br> &nbsp; &nbsp;at next (/var/www/securing-restful-apis-with-jwt/node_modules/express/lib/router/index.js:275:10)</pre>
</body>
</html>

相关内容