我正在开发一个带有 Angular 前端的 Spring Boot 应用程序,该前端充当基本的登录门户。登录门户使用加密凭据并单击验证来验证用户身份。我的目标是根据用户是通过服务器的 IP 地址还是域名访问应用程序来区分行为。 所需功能:
When accessing the server via its IP address (e.g., 0.0.0.0:8080): Users should be directed to the Angular login page. Once authenticated, they would have access to a control panel for managing server settings (IPs, files, etc.).
When accessing the server via a domain name (e.g., example.com:8080): The server should serve a different website (an index.html or multi-page site) rather than the Angular control panel.
我做了什么:
I know how to handle HTTP requests in Java with Spring Boot and how to serve the Angular frontend as a static resource. However, I’m unsure how to programmatically differentiate requests based on whether the user is accessing the site by IP or domain name and serve different content accordingly.
关键问题:
How can I configure my Spring Boot application to detect whether the user is accessing via IP address or domain name and serve different content?
Should this logic reside in Java (Spring Boot) or should Angular handle the request and pass the URL to the backend for processing?
Are there specific libraries, configurations, or strategies I can use to achieve this, particularly when dealing with both Angular and static HTML pages in the same application?
附加信息:
The application is similar to Webmin, Plesk, or cPanel, where the control panel is accessed via IP while a public-facing website is served when a domain is used.
The Angular front end is primarily for server management (changing files, updating emails, etc.).
任何有关如何解决此问题的指导或建议将不胜感激!