Hey Tom, We have some examples that should be close to what you need in the AMBARIUI and the associated AMBARI service definition and rewrite rules.
https://github.com/apache/knox/blob/master/gateway-service-definitions/src/main/resources/services/ambari/2.2.0/rewrite.xml#L31 Please note that the content type here as a special ‘asType’ tag that you should not need. That was a special provision provided for Ambari as they return a text/plain content type in their REST responses even if the content is JSON. Just marking up your content as application/json should be enough. Also please note, for all UI services so far, there has been a separation for the REST API service definition so that the REST client’s can be proxied as per usual without the UI. <https://github.com/apache/knox/blob/master/gateway-service-definitions/src/main/resources/services/ambari/2.2.0/rewrite.xml#L31> HTH, Sumit <https://github.com/apache/knox/blob/master/gateway-service-definitions/src/main/resources/services/ambari/2.2.0/rewrite.xml#L31> From: "Ellis, Tom (Financial Markets IT)" <[email protected]<mailto:[email protected]>> Reply-To: "[email protected]<mailto:[email protected]>" <[email protected]<mailto:[email protected]>> Date: Monday, July 18, 2016 at 7:40 AM To: "[email protected]<mailto:[email protected]>" <[email protected]<mailto:[email protected]>> Subject: RE: Rewrite javascipt In addition to this, the SOLR admin makes a number of queries which return json, which actually has fields that is json again themselves, e.g: {"znode":{“data”:”{\n \”base_url\”:\”mysolrhost:8983/solr\”… Is it possible for Knox to rewrite the base_url path? Cheers, Tom Ellis [email protected]<mailto:[email protected]> From: Ellis, Tom (Financial Markets IT) [mailto:[email protected]] Sent: 15 July 2016 10:58 To: [email protected]<mailto:[email protected]> Subject: Rewrite javascipt -- This email has reached the Bank via an external source -- Hi There, I’m trying to set up a service for the Solr Admin UI. I’ve been using the quick tutorial on the weather service by Kevin Minder as well as looking at the community provided samples for the Yarn UI etc. I’ve got as far as getting the CSS/Images and stuff to display properly for Solr, but am having trouble rewriting the Javascript. Within the returned HTML for the console I can see the following: <script type="text/javascript"> var app_config = {}; app_config.solr_path = '\/solr'; app_config.core_admin_path = '\/admin\/cores'; </script> I can also see an error in Chrome Developer tools about getting a 404 for: https://myknoxhost:8443/solr/admin/cores?wt=json&indexInfo=false&_=1468576373998 I believe I need to rewrite the app_config.solr_path to be something like ‘\/gateway\/default\/solr’ but am not sure how to do so. Here is the latest of my attempts: rewrite.xml: <rules> <rule dir="IN" name="SOLR/solr/inbound/root" pattern="*://*:*/**/solr/"> <rewrite template="{$serviceUrl[SOLR]}/solr/"/> </rule> <rule dir="IN" name="SOLR/solr/inbound/path" pattern="*://*:*/**/solr/{**}"> <rewrite template="{$serviceUrl[SOLR]}/solr/{**}"/> </rule> <rule dir="OUT" name="SOLR/solr/outbound/jsroot" pattern="\/solr" > <rewrite template="\/gateway\/default\/solr" /> </rule> <rule dir="OUT" name="SOLR/solr/outbound/root" pattern="/solr/"> <rewrite template="{$frontend[url]}/solr/" /> </rule> <rule dir="OUT" name="SOLR/solr/outbound/path" pattern="/solr/{**}"> <rewrite template="{$frontend[url]}/solr/{**}" /> </rule> <filter name="SOLR/solr/outbound"> <content type="*/html"> <apply path="https?://[^/':,]+:[\d]+/solr/[^']*" rule="SOLR/solr/outbound/path" /> </content> <content type="*/javascript"> <apply path="\/solr" rule="SOLR/solr/outbound/jsroot" /> </content> </filter> </rules> service.xml <service role="SOLR" name="solr" version="5.2.1"> <routes> <route path="/solr/"> <rewrite apply="SOLR/solr/outbound" to="response.body"/> </route> <route path="/solr/**"> <rewrite apply="SOLR/solr/outbound" to="response.body"/> </route> </routes> </service> default.xml … Other services/providers … <service> <role>SOLR</role> <url>http://myknoxhost:8983</url<http://myknoxhost:8983%3c/url>> </service> … Does anyone have any tips? Cheers, Tom Ellis [email protected]<mailto:[email protected]> Lloyds Banking Group plc. Registered Office: The Mound, Edinburgh EH1 1YZ. Registered in Scotland no. SC95000. Telephone: 0131 225 4555. Lloyds Bank plc. Registered Office: 25 Gresham Street, London EC2V 7HN. Registered in England and Wales no. 2065. Telephone 0207626 1500. Bank of Scotland plc. Registered Office: The Mound, Edinburgh EH1 1YZ. Registered in Scotland no. SC327000. Telephone: 03457 801 801. Cheltenham & Gloucester plc. Registered Office: Barnett Way, Gloucester GL4 3RL. Registered in England and Wales 2299428. Telephone: 0345 603 1637 Lloyds Bank plc, Bank of Scotland plc are authorised by the Prudential Regulation Authority and regulated by the Financial Conduct Authority and Prudential Regulation Authority. Cheltenham & Gloucester plc is authorised and regulated by the Financial Conduct Authority. Halifax is a division of Bank of Scotland plc. Cheltenham & Gloucester Savings is a division of Lloyds Bank plc. HBOS plc. Registered Office: The Mound, Edinburgh EH1 1YZ. Registered in Scotland no. SC218813. This e-mail (including any attachments) is private and confidential and may contain privileged material. If you have received this e-mail in error, please notify the sender and delete it (including any attachments) immediately. You must not copy, distribute, disclose or use any of the information in it or any attachments. Telephone calls may be monitored or recorded. Lloyds Banking Group plc. Registered Office: The Mound, Edinburgh EH1 1YZ. Registered in Scotland no. SC95000. Telephone: 0131 225 4555. Lloyds Bank plc. Registered Office: 25 Gresham Street, London EC2V 7HN. Registered in England and Wales no. 2065. Telephone 0207626 1500. Bank of Scotland plc. Registered Office: The Mound, Edinburgh EH1 1YZ. Registered in Scotland no. SC327000. Telephone: 03457 801 801. Cheltenham & Gloucester plc. Registered Office: Barnett Way, Gloucester GL4 3RL. Registered in England and Wales 2299428. Telephone: 0345 603 1637 Lloyds Bank plc, Bank of Scotland plc are authorised by the Prudential Regulation Authority and regulated by the Financial Conduct Authority and Prudential Regulation Authority. Cheltenham & Gloucester plc is authorised and regulated by the Financial Conduct Authority. Halifax is a division of Bank of Scotland plc. Cheltenham & Gloucester Savings is a division of Lloyds Bank plc. HBOS plc. Registered Office: The Mound, Edinburgh EH1 1YZ. Registered in Scotland no. SC218813. This e-mail (including any attachments) is private and confidential and may contain privileged material. If you have received this e-mail in error, please notify the sender and delete it (including any attachments) immediately. You must not copy, distribute, disclose or use any of the information in it or any attachments. Telephone calls may be monitored or recorded.
