GF 3.0.1 +虚拟服务器:www.myhost.com:8080/projectname-war => www.myhost.com。如何?
编辑
我需要将www.myhost.com:8080/myproject-war
更改为www.myhost.com
。这是我一直在尝试的:
我配置虚拟服务器:服务器
。我仍然有默认的网络侦听器 http-listener-1 和 http-listner-2。我将默认 Web 模块更改为 ScholarActive#ScholarActive-war.war
(下拉列表中的唯一选项,因为我只部署 1 个应用程序)。
对于docroot
,我尝试这个
${com.sun.aas.instanceRoot}/applications/ScholarActive/ScholarActive-war_war
或这个
${com.sun.aas.instanceRoot}/applications/ScholarActive/
都不起作用。 为了使其工作,docroot 需要指向什么?
我尝试做的是:当我输入 localhost:8080/ScholarActive-war 时,然后加载我的应用程序,我想要这样:我输入 locahost:8080,它也会加载应用程序,然后剩下的就是将端口更改为 80。但没有运气。有什么想法吗?
EDIT
I need to change www.myhost.com:8080/myproject-war
to www.myhost.com
. Here is what I've been trying:
I configurate the Virtual Server: server
. I have still have default Network Listeners to be http-listener-1 and http-listner-2. I change the Default Web Module to ScholarActive#ScholarActive-war.war
(The only option in the drop down list, since I only deploy 1 application).
For the docroot
, I try this
${com.sun.aas.instanceRoot}/applications/ScholarActive/ScholarActive-war_war
or this
${com.sun.aas.instanceRoot}/applications/ScholarActive/
Both does not work. What does docroot need to point to, for this to work?
what I try to do is: when I type localhost:8080/ScholarActive-war, then my application load, I want to make so that if I type locahost:8080, it will load the app as well, then what left is changed the port to 80. But no luck. Any Idea?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
如果您可以以root身份运行glassfish,只需编辑domain.xml文件,将端口8080更改为端口80。
如果您不想以root身份运行glassfish(因为您不应该这样做),那么您可以使用apache来前端glassfish 。我在博客中介绍了 运行 glassfish v2和 v3 位于 apahce httpd 后面。
或者,您可以使用 iptables 将所有流量从端口 80 路由到端口 8080,如下所示:
至于问题的第二部分 - 删除上下文根,只需使用“/”上下文根部署应用程序即可。再次有几种方法可以实现这一目标。您可以在部署期间或之后使用管理 Web 控制台设置 Web 应用程序的上下文根。您可以通过命令行设置它:
或者您可以将 sun-web.xml 文件的上下文根设置为 /。
或者,您可以为虚拟服务器设置默认 Web 模块,类似于 Web 管理控制台是端口 4848 的默认 Web 模块。但我从未尝试过此操作。
回答编辑后的问题:
要更改默认 Web 模块,请从 glassfish 管理控制台 (localhost:4848) 转到:
Configuration ->虚拟服务器 -> server
您将在此处看到“默认 Web 模块”的下拉列表。选择您部署的 Web 应用程序。该应用程序现在将响应根 URL。我自己尝试后注意到,登录后我被重新路由到上下文根。这可以通过将我的 web 应用程序的上下文 Roop 设置为“”/”来解决,或者使用
另一种可能性是在apache httpd中使用mod_proxy,并将80端口的“/”映射到端口 8080 上的“/myWebApp”。这完全避免了上述混乱。
If you are ok about running glassfish as root, simply edit the domain.xml file, changing port 8080 to port 80.
If you do not want to run glassfish as root (as you shouldn't), then you can front glassfish with apache. I blogged about running both glassfish v2 and v3 behind apahce httpd.
Alternatively, you can use iptables to route all traffic from port 80 to port 8080 like so:
As for the 2nd part of the question - removing the context root, it's just a matter of deploying your application with a "/" context root. There are again a few ways to achieve this. You can set the context root for your webapp using the Admin web console, during, or after it's deployed. You can set it via the command line:
Or you can set the context-root of your sun-web.xml file to /.
Alternatively, you could set the default web module for a virtual server, similarly to how the web admin console is the default web module for port 4848. I've never tried this though.
Answering the edited question:
To change the default web module, from the glassfish admin console (localhost:4848), goto:
Configuration -> Virtual Servers -> server
There you will see a drop-down list for the "Default Web Module". Select your deployed web application. This application will now respond on the root url. I noticed after trying this myself, that I was re-routed to the context root after logging in. This could possibly be fixed by setting the context roop of my webapp to ""/", or by using the
Yet another possibility, is to use mod_proxy in apache httpd, and map "/" of port 80 to "/myWebApp" on port 8080. This avoids the above mess altogether.
在您的Web容器中,您应该将/myproject-war设置为根路径,然后将监听端口从8080更改为80。重新启动Web容器,您可以通过
http://localhost/,如果您想使用
http://www.myhost.com
代替,请添加一行,例如www.myhost.com 127.0.0.1
位于主机文件末尾。这仅适用于本地网站。In your web container,you should set /myproject-war as the root path, then change the listening port from 8080 to 80. Restart the web container,you can browser you web through
http://localhost/
,if you want to usehttp://www.myhost.com
instead, add a line likewww.myhost.com 127.0.0.1
at the end of you hosts file.This just works for local web site.大多数情况下,我在 tomcat/jboss/jetty 前面使用 apache 和 mod_proxy 或 mod_jk。这样,apache 就会监听端口 80/443,并在端口 8080/8443(或 mod_jk 的 8009)上与 j2ee 服务器通信。
Most often I front tomcat/jboss/jetty with apache and mod_proxy or mod_jk. This way, apache listens on port 80/443, and speaks to the j2ee server on port 8080/8443 (or 8009 for mod_jk).
我认为 Glassfish Web 容器是基于 tomcat 的,在 tomcat 中您可以调用您的 Web 应用程序文件 ROOT.WAR 来执行您想要的操作。尝试调用您的网络应用程序 ROOT.war 并查看是否符合您的要求,并告诉我们。
无法从 web.xml 中配置您想要的内容,因为它只包含供应商中立的设置。您需要更改的设置是特定于应用程序服务器的。如果您编辑您的帖子并让我们知道您正在使用哪个应用程序服务器,我们可以为您指明如何做您想做的事情的正确方向。
I think that the Glassfish web container is based on tomcat with tomcat you can call your web app file ROOT.WAR which does what you want. Try calling your web app ROOT.war and see if that does what you want, and let us know.
There is no way to configure what you want from within web.xml since it only contains vendor neutral setting. The settings you need to change are application server specific. If you edit your post and let us know which application server you are using we can point you in the right direction on how to do what you want.
此页面为我提供了解决方案。
http://blogs.oracle.com/alexismp/entry/glassfish_tip_have_your_application
但是,我的安全身份验证是 jdbcRealm,在我登录后,glassfish 会自动将 my-project-war 附加到我的 URL 上。那么
就会提示我登录
www.myhost.com在我登录后
,它变成了www.myhost.com/my-project-war
这是为什么呢?
This page provide me the solution.
http://blogs.oracle.com/alexismp/entry/glassfish_tip_have_your_application
However, my security authentication is
jdbcRealm
, right after I log in, glassfish automatically append the my-project-war on my URL. Sowww.myhost.com will prompt me to login
right after I login, it became
www.myhost.com/my-project-war
why is that?