简体   繁体   English

Apache hybris 配置代理将 HTTP 和 HTTP(S) yacceleratorstorefront(电子商店)URL 传递到 Hybris 服务器

[英]Apache hybris configuration to proxy pass HTTP and HTTP(S) yacceleratorstorefront (electronic store) URL to Hybris Server

I am trying to access the yacceleratorstorefront/electronics/en/?site=electronics URL from apache web server to Hybris where the electronic store URL is configured.我正在尝试从 apache Web 服务器访问 yacceleratorstorefront/electronics/en/?site=electronics URL 到配置了电子商店 URL 的 Hybris。 The electronic store URL is accessible and working from any of the server in environment if apache web server is BY PASSED如果 apache Web 服务器被 BY PASSED,则电子商店 URL 可从环境中的任何服务器访问和工作

http://10.0.1.141:9001 is my Hybris server. http://10.0.1.141:9001是我的 Hybris 服务器。

ERROR ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━错误 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

HTTP Status 500 - Cannot find CMSSite associated with current URL ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ HTTP 状态 500 - 找不到与当前 URL 关联的 CMSSite ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

type Status report类型状态报告

message Cannot find CMSSite associated with current URL消息找不到与当前 URL 关联的 CMSSite

description The server encountered an internal error that prevented it from fulfilling this request.说明 服务器遇到内部错误,无法完成此请求。

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Any suggestion or advice is highly appreciated.任何建议或意见都非常感谢。 Thank you in advance.先感谢您。

-Regards, S@BS -问候,S@BS

------------------------------------------------httpd Code below---------------------------------------------------- ------------------------------------------------httpd 代码以下 - - - - - - - - - - - - - - - - - - - - - - - - - ---

<VirtualHost *:80> <虚拟主机 *:80>
ProxyPreserveHost On ProxyPreserveHost On

ProxyPass / http://10.0.1.141:9001/ ProxyPass / http://10.0.1.141:9001/
ProxyPassReverse / http://10.0.1.141:9001/ ProxyPassReverse / http://10.0.1.141:9001/

ServerName localhost服务器名称本地主机
</VirtualHost> </虚拟主机>

<VirtualHost *:443> <虚拟主机 *:443>
ServerName localhost服务器名称本地主机

#ProxyRequests Off #ProxyRequests 关闭
#ProxyPreserveHost On #ProxyPreserveHost 开启
ProxyPass / https://10.0.1.141:9002/yacceleratorstorefront/electronics/en/?site=electronics ProxyPass / https://10.0.1.141:9002/yacceleratorstorefront/electronics/en/?site=electronics
ProxyPassReverse / https://10.0.1.141:9002/yacceleratorstorefront/electronics/en/?site=electronics ProxyPassReverse / https://10.0.1.141:9002/yacceleratorstorefront/electronics/en/?site=electronics


SSLEngine on SSL引擎开启
SSLCertificateFile /etc/httpd/certs/mysite.com.crt SSLCertificateFile /etc/httpd/certs/mysite.com.crt
SSLCertificateKeyFile /etc/httpd/certs/mysite.com.key SSLCertificateKeyFile /etc/httpd/certs/mysite.com.key


</VirtualHost> </虚拟主机>

 

The error message indicates that you are not setting the ?site=electronics parameter at the http version of you proxy (it also seems to be missing in the proxypass setting for port 80).该错误消息表明您没有在代理的 http 版本中设置?site=electronics参数(它似乎也没有出现在端口 80 的 proxypass 设置中)。 I'm not an apache buff but maybe it works if you configure your proxy settings for port 80 in the same way:我不是 apache 爱好者,但如果您以相同的方式为端口 80 配置代理设置,也许它会起作用:

<VirtualHost *:80>
ProxyPreserveHost On

ProxyPass / http://10.0.1.141:9001/?site=electronics
ProxyPassReverse / http://10.0.1.141:9001/?site=electronics

ServerName localhost
</VirtualHost>

Just some more info: Apart from the site parameter approach you can also use a host name approach.更多信息:除了site参数方法之外,您还可以使用主机名方法。 Not sure if you have access to the hybris wiki, but here are some more details: https://wiki.hybris.com/display/pmtelco/Using+Modulegen+to+Create+a+B2C+Telco+Setup#UsingModulegentoCreateaB2CTelcoSetup-AccessingtheStorefront (its for Telco accelerator, but it works the same for any other storefront).不确定您是否可以访问 hybris wiki,但这里有更多详细信息: https : //wiki.hybris.com/display/pmtelco/Using+Modulegen+to+Create+a+B2C+Telco+Setup#UsingModulegentoCreateaB2CTelcoSetup-访问店面(它适用于电信加速器,但它对任何其他店面的工作方式相同)。 Not sure how that works together with apache, I assume you have to setup some sub domains or something.不确定它是如何与 apache 一起工作的,我假设您必须设置一些子域或其他内容。

Does it work if you try to access apache on https directly?如果您尝试直接在 https 上访问 apache 是否有效? (There it seems you have the correct url containing the site parameter). (在那里,您似乎拥有包含站点参数的正确 url)。

Note: The site parameter is basically only needed for the first http request of a session.注意:site 参数基本上只需要会话的第一个 http 请求。 It is used to determine which storefront, ie BaseSite is supposed to be used.它用于确定应该使用哪个店面,即 BaseSite。 All subsequent requests (of the same session) shouldn't require the site parameter.所有后续请求(同一会话的)不应需要 site 参数。

Hope that helps!希望有帮助!

Your http config is fine.你的 http 配置没问题。 Your https config is wrong.你的 https 配置是错误的。

Do not put ?site=electronics or anything like that in your apache config.不要把 ?site=electronics 或类似的东西放在你的 apache 配置中。

The site detection works based on the URL.站点检测基于 URL 工作。 In the sample data you are using that is at least a regex looking for "electronics" in the hostname.在您使用的示例数据中,至少是一个在主机名中查找“电子”的正则表达式。

One single apache config will be able to support all sites.一个单一的 apache 配置将能够支持所有站点。 You do not need to specify the site.您不需要指定站点。 You do not need to specify /yacceleratorstorefront.您不需要指定 /yacceleratorstorefront。

Simply edit your hosts file to include "10.0.1.141 electronics.rtfm"只需编辑您的主机文件以包含“10.0.1.141electronics.rtfm”

Now access http://electronics.rtfm/现在访问http://electronics.rtfm/

You can avoid adding the site in the URL by going in HMC: WCMS > Websites您可以通过进入 HMC 来避免在 URL 中添加站点: WCMS > Websites
Under the Properties tab, add a new URL pattern that will match your site.在“ Properties选项卡下,添加与您的站点匹配的新 URL 模式。

Once it is done, URLs that match the site's pattern will automatically use that site.完成后,与站点模式匹配的 URL 将自动使用该站点。

Using URL patterns for each site will simplify the web server's configuration.为每个站点使用 URL 模式将简化 Web 服务器的配置。

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

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