简体   繁体   English

如何使Moqui中Screens上的链接的URL是相对的而不是绝对的?

[英]How to make the url of links on Screens in Moqui to be relative rather than absolute?

The link for JavaScript and CSS files appear to have an absolute URL like: JavaScript和CSS文件的链接似乎具有绝对网址,例如:

    <script type="text/javascript" src="http://test.dp.com:8080/js/jquery-1.9.1.min.js"  language="javascript">
    <script type="text/javascript" src="http://test.dp.com:8080/js/bootstrap.min.js" language="javascript">
    <script type="text/javascript" src="http://test.dp.com:8080/js/holder.js" language="javascript">
    <link type="text/css" href="css/bootstrap.css" rel="stylesheet">

but I would like them to be: 但我希望他们是:

    <script type="text/javascript" src="js/jquery-1.9.1.min.js" language="javascript">
    <script type="text/javascript" src="js/bootstrap.min.js" language="javascript">
    <script type="text/javascript" src="holder.js" language="javascript">
    <link type="text/css" href="css/bootstrap.css" rel="stylesheet">

It is also similar to the link on Screen. 它也类似于屏幕上的链接。

I would like to have them relative, then it can be possible to add a reverse proxy in front of the application. 我希望它们是相对的,然后可以在应用程序前面添加反向代理。

These come from the Header.html.ftl file in the webroot component and use values like this: 这些来自webroot组件中的Header.html.ftl文件,并使用如下值:

${sri.buildUrl(scriptLocation).url}

There are many URLs generated like this with the full URL including hostname and such. 像这样生成的许多URL都有完整的URL,包括主机名等。 When not running locally you'll almost always need to set the external hostname and ports in the Moqui Conf XML file. 如果不在本地运行,则几乎总是需要在Moqui Conf XML文件中设置外部主机名和端口。 For example: 例如:

<webapp-list>
    <webapp name="webroot" http-host="www.mydomain.com" http-port="80" https-enabled="false">
        <root-screen host=".*" location="component://webroot/screen/webroot.xml"/>
    </webapp>
</webapp-list>

Note that this still has https-enabled="false". 请注意,这仍然具有https-enabled =“ false”。 If you set that to true also set the @https-host and @https-post attributes. 如果将其设置为true,则还要设置@ https-host和@ https-post属性。

Note that if you leave any of http-host, http-port, https-host, or https-port empty they will default to the hostname and port on the HTTP request. 请注意,如果您将http-host,http-port,https-host或https-port中的任何一个保留为空,则它们将默认为HTTP请求上的主机名和端口。 This is the way to handle it for virtual hosting for multi-tenant or multi-root screen setups. 这是用于多租户或多根屏幕设置的虚拟主机处理它的方法。 For this to work it is necessary that any load balancer or other other proxy (such as mod-proxy on httpd) be setup to pass through this HTTP request information. 为此,必须设置任何负载平衡器或其他代理(例如httpd上的mod-proxy)以通过此HTTP请求信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM