如何使用apache ProxyPass通配符本地虚拟主机子域
how to ProxyPass Wildcard local virtualhost subdomain with apache
所以我在本地开发了 Node.js 应用程序。我在本地制作了 apache 虚拟主机来测试子域功能。假设域是 bloggin.fun
,那么每个用户都会有自己的子域。 alexis.bloggin.fun
等。如何使用通配符子域然后代理将其传递给所需的 URL.
我也从 Stack Overflow 遵循的当前设置给了我 chrome 未找到错误。未重定向到 localhost:4040/auth
<VirtualHost *:80>
ServerName bloggin.fun
ServerAlias hplus.onlocal
ProxyPass / http://localhost:4040/
ProxyPassReverse / http://localhost:4040/
</VirtualHost>
<VirtualHost *:80>
ServerAlias *.bloggin.fun
ProxyPass / http://localhost:4040/blog
ProxyPassReverse / http://localhost:4040/blog
</VirtualHost>
我的/etc/hosts
是这样的
127.0.0.1 bloggin.fun
我做错了什么?如何使用 apache 代理传递子域通配符?因此,当我访问 alexis.bloggin.fun
时,将被代理到 'http:localhost:4040/auth'
问题是 /etc/hosts
是逐字评估的,没有发生递归 - 这与 DNS 完全不同,在 DNS 中您有递归解析器。
要测试子域,您还需要指定它们的分辨率:
127.0.0.1 bloggin.fun alexis.bloggin.fun tom.bloggin.fun freddie.bloggin.fun
所以我在本地开发了 Node.js 应用程序。我在本地制作了 apache 虚拟主机来测试子域功能。假设域是 bloggin.fun
,那么每个用户都会有自己的子域。 alexis.bloggin.fun
等。如何使用通配符子域然后代理将其传递给所需的 URL.
我也从 Stack Overflow 遵循的当前设置给了我 chrome 未找到错误。未重定向到 localhost:4040/auth
<VirtualHost *:80>
ServerName bloggin.fun
ServerAlias hplus.onlocal
ProxyPass / http://localhost:4040/
ProxyPassReverse / http://localhost:4040/
</VirtualHost>
<VirtualHost *:80>
ServerAlias *.bloggin.fun
ProxyPass / http://localhost:4040/blog
ProxyPassReverse / http://localhost:4040/blog
</VirtualHost>
我的/etc/hosts
是这样的
127.0.0.1 bloggin.fun
我做错了什么?如何使用 apache 代理传递子域通配符?因此,当我访问 alexis.bloggin.fun
时,将被代理到 'http:localhost:4040/auth'
问题是 /etc/hosts
是逐字评估的,没有发生递归 - 这与 DNS 完全不同,在 DNS 中您有递归解析器。
要测试子域,您还需要指定它们的分辨率:
127.0.0.1 bloggin.fun alexis.bloggin.fun tom.bloggin.fun freddie.bloggin.fun