如何使用域名访问本地Web应用程序,而不是localhost / IP地址? [英] How to access the local web application with domain name instead of localhost/IP address?

查看:489
本文介绍了如何使用域名访问本地Web应用程序,而不是localhost / IP地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个托管在本地Tomcat服务器上的基于Java的Web应用程序。到目前为止,我正在使用如 http:// localhost:8080 / myApp 这样的URL进行访问。但是我想使用域名访问它,例如 http://us.localApp.com/myApp 。 Simlilary我想要其他的网络上的机器,只能通过这个域名URL进行访问。我必须在我的应用程序或Tomcat设置中进行更改,或者我需要提到
一个条目,如 127.0.0.1 us.localApp.com 在我的 主机文件中。



我可以在 appConfig.xml 中看到这个条目,还看到有些人使用 localApp.com< !ENTITY appDomainlocalApp.com> ,但我该怎么办?



我已经输入了 127.0.0.1 google.com 主机文件中。当我输入 http://google.com 时,我希望它重定向到本地应用程序,即我的应用程序,但仍然它将进入Google网站。为什么?

解决方案

主机文件是我想到的最简单的方法,但需要在每台机器上本地实现。另一种方法是在您的网络上安装本地DNS服务器,并将该特定DNS请求路由到您的应用服务器。


I have a Java based webapplication hosted on a local Tomcat server. As of now, I am accessing it with a URL like http://localhost:8080/myApp. But I want to access it with a domain name, something like http://us.localApp.com/myApp. Simlilary I want other's machines, which are on the network, to access it by this domain URL only. Do I have to make the changes in my application or Tomcat settings for this or do I need to mention just an entry like 127.0.0.1 us.localApp.com in my hosts file.

I can see this entry in appConfig.xml and also saw some people accessing with localApp.com <!ENTITY appDomain "localApp.com">, but how should I go about it?

I have made the entry 127.0.0.1 google.com in the hosts file. When I type http://google.com I expect it redirect to the local application, that is, my application, but still it is going to the Google site. Why?

解决方案

The hosts file is the easiest way I can think of, but it will need to be implemented locally on each machine. The alternative would be to install a local DNS server on your network and route that specific DNS request to your application server.

这篇关于如何使用域名访问本地Web应用程序,而不是localhost / IP地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆