是否可以使用 Windows IIS 上 运行 的嵌入式 Tomcat Web 服务器从 URL 删除 Spring 启动应用程序的端口?

Is it possible to remove the port from the URL for a Spring Boot application using an embedded Tomcat web server that is running on Windows IIS?

执行 Spring 启动带有嵌入式 tomcat Web 服务器的应用程序 运行 在 IIS 之上作为执行的 JAR 文件始终需要在 URL 中指定端口为了在浏览器中点击应用程序?

是的,如果您使用默认端口 80。假设您的应用程序 运行 位于 1.1.1.1:80,您可以通过 1.1.1.1 或 1.1.1.1:80

访问它

所有生产应用程序 url 在其 url 中没有端口号,它在内部网络或 运行 网络上或 public 网络上。另一方面,基于 java 的应用程序服务器 运行s 在 80 以外的端口上,例如默认情况下 tomcat 运行s 在 8080 上。我们可以将 tomcat 的默认端口更改为 80,但我们使用像 nginx 这样的 Web 服务器并将其设置为 运行 端口 80 并将请求转发给 tomcat 或 java 应用程序服务器。

使用像 nginx 这样的 web/proxy 服务器有以下好处,它 运行 在端口 80 上,而不是将 tomcat 或应用程序服务器的端口更改为 80。

  1. 在生产环境tomcat/other个应用服务器运行多个节点中,我们可以使用nginx作为负载均衡器。
  2. 繁琐的url在这里轻松美化了(这里去掉了端口号)
  3. nginx之类的服务器有很多优点,大家可以google了解一下。

以下线程解释了将请求从 nginx 转发到 tomcat。

Nginx configuration to pass site directly to tomcat webapp with context