Http-server无需端口即可访问应用程序
Http-server to access the application without port
所以我有一个 Web 应用程序 运行 通过 npm 在 http 服务器上。在我的 package.jsonfile 中,我有行 "start":"http-server dist --ssl",当我转到 https://myipaddress:8080. However if I change the url to just http://myipaddress 时,我的应用程序 运行 正常,但我无法访问该应用程序
简而言之,我如何 运行 应用程序才能从 https://myipaddress and not https://myipaddress:8080 访问它?
没有特殊插件的浏览器(即 HTTPS Everywhere)需要 http://
方案的端口 80。如果您使用 https://myipaddress
,那么它需要端口 443。
因此,为了让浏览器调用 http://myipaddress
,您需要执行两个操作:
- 从 HTTP 到 HTTPS 的重定向(来自 http://myipaddress:80 to http://myipaddress:443)
- 您的应用程序监听端口 443,这样 https://myipaddress 就可以工作了
NGINX 或其他反向代理可能会有所帮助。
您可以让 http-server
在没有 SSL 的情况下侦听 localhost:8080
并放置 NGINX,以便它将 http://myipaddress:80
重定向到 https://myipaddress:443
并代理 https://myipaddress:443
到 http://localhost:8080
此外,请记住,监听低于 1024 的端口需要 Unix 系统上的 root 用户权限。
所以我有一个 Web 应用程序 运行 通过 npm 在 http 服务器上。在我的 package.jsonfile 中,我有行 "start":"http-server dist --ssl",当我转到 https://myipaddress:8080. However if I change the url to just http://myipaddress 时,我的应用程序 运行 正常,但我无法访问该应用程序
简而言之,我如何 运行 应用程序才能从 https://myipaddress and not https://myipaddress:8080 访问它?
没有特殊插件的浏览器(即 HTTPS Everywhere)需要 http://
方案的端口 80。如果您使用 https://myipaddress
,那么它需要端口 443。
因此,为了让浏览器调用 http://myipaddress
,您需要执行两个操作:
- 从 HTTP 到 HTTPS 的重定向(来自 http://myipaddress:80 to http://myipaddress:443)
- 您的应用程序监听端口 443,这样 https://myipaddress 就可以工作了
NGINX 或其他反向代理可能会有所帮助。
您可以让 http-server
在没有 SSL 的情况下侦听 localhost:8080
并放置 NGINX,以便它将 http://myipaddress:80
重定向到 https://myipaddress:443
并代理 https://myipaddress:443
到 http://localhost:8080
此外,请记住,监听低于 1024 的端口需要 Unix 系统上的 root 用户权限。