remap rules based on request header

classic Classic list List threaded Threaded
21 messages Options
12
Reply | Threaded
Open this post in threaded view
|

remap rules based on request header

Adi Mallikarjuna Reddy V
Is there a config that allows to change remap rule based on the incoming header?


My use case is , if I send a custom header in the request, the remap rule should be changed to different one than the default one configured.


Thanks
Adi
Reply | Threaded
Open this post in threaded view
|

Re: remap rules based on request header

Brian Geffon-2
There is a regex_remap plugin that is what you would want, take a look in plugins/

Brian

On Tue, Jan 24, 2017, 11:25 Adi Mallikarjuna Reddy V <[hidden email]> wrote:
Is there a config that allows to change remap rule based on the incoming header?


My use case is , if I send a custom header in the request, the remap rule should be changed to different one than the default one configured.


Thanks

Adi
Reply | Threaded
Open this post in threaded view
|

Re: remap rules based on request header

Brian Geffon-2

Sorry I think I meant header_rewrite.

Brian


On Tue, Jan 24, 2017, 11:26 Brian Geffon <[hidden email]> wrote:
There is a regex_remap plugin that is what you would want, take a look in plugins/

Brian


On Tue, Jan 24, 2017, 11:25 Adi Mallikarjuna Reddy V <[hidden email]> wrote:
Is there a config that allows to change remap rule based on the incoming header?


My use case is , if I send a custom header in the request, the remap rule should be changed to different one than the default one configured.


Thanks

Adi
Reply | Threaded
Open this post in threaded view
|

Re: remap rules based on request header

Adi Mallikarjuna Reddy V
So to achieve my use case, can I try something like this?

map / http://b.bar.com @plugin=header_rewrite.so @pparam=rules1.conf
and my rules1.conf has
cond %{HEADER:MY_HEADER} = "foo"
set-destination HOST mobile.bar.com [L]
This should forward the request to mobile.bar.com if the request has 'MY_HEADER' with value 'foo'.

Thanks
Adi


On Tue, Jan 24, 2017 at 11:36 AM, Brian Geffon <[hidden email]> wrote:

Sorry I think I meant header_rewrite.

Brian


On Tue, Jan 24, 2017, 11:26 Brian Geffon <[hidden email]> wrote:
There is a regex_remap plugin that is what you would want, take a look in plugins/

Brian


On Tue, Jan 24, 2017, 11:25 Adi Mallikarjuna Reddy V <[hidden email]> wrote:
Is there a config that allows to change remap rule based on the incoming header?


My use case is , if I send a custom header in the request, the remap rule should be changed to different one than the default one configured.


Thanks

Adi

Reply | Threaded
Open this post in threaded view
|

Re: remap rules based on request header

Jeremy Payne
the lua plugin also has this functionality although may be somewhat overkill for your needs.


On Tue, Jan 24, 2017 at 1:43 PM, Adi Mallikarjuna Reddy V <[hidden email]> wrote:
So to achieve my use case, can I try something like this?

map / http://b.bar.com @plugin=header_rewrite.so @pparam=rules1.conf
and my rules1.conf has
cond %{HEADER:MY_HEADER} = "foo"
set-destination HOST mobile.bar.com [L]
This should forward the request to mobile.bar.com if the request has 'MY_HEADER' with value 'foo'.

Thanks
Adi


On Tue, Jan 24, 2017 at 11:36 AM, Brian Geffon <[hidden email]> wrote:

Sorry I think I meant header_rewrite.

Brian


On Tue, Jan 24, 2017, 11:26 Brian Geffon <[hidden email]> wrote:
There is a regex_remap plugin that is what you would want, take a look in plugins/

Brian


On Tue, Jan 24, 2017, 11:25 Adi Mallikarjuna Reddy V <[hidden email]> wrote:
Is there a config that allows to change remap rule based on the incoming header?


My use case is , if I send a custom header in the request, the remap rule should be changed to different one than the default one configured.


Thanks

Adi


Reply | Threaded
Open this post in threaded view
|

Re: remap rules based on request header

Adi Mallikarjuna Reddy V
Ok, I tried the following one with no luck. The requests are always going to the new host without the customer header value also.

cond %{HEADER:DEV_HOST} = "dev102"
set-destination HOST dev102.abc.com [L]



my remap rule is

map / http://abc.com/ @pristine_host_hdr=1 @plugin=header_rewrite.so @pparam=my_header_rules.conf


Am I missing anything important here?


Thanks

Adi


On Tue, Jan 24, 2017 at 11:46 AM, Jeremy Payne <[hidden email]> wrote:
the lua plugin also has this functionality although may be somewhat overkill for your needs.


On Tue, Jan 24, 2017 at 1:43 PM, Adi Mallikarjuna Reddy V <[hidden email]> wrote:
So to achieve my use case, can I try something like this?

map / http://b.bar.com @plugin=header_rewrite.so @pparam=rules1.conf
and my rules1.conf has
cond %{HEADER:MY_HEADER} = "foo"
set-destination HOST mobile.bar.com [L]
This should forward the request to mobile.bar.com if the request has 'MY_HEADER' with value 'foo'.

Thanks
Adi


On Tue, Jan 24, 2017 at 11:36 AM, Brian Geffon <[hidden email]> wrote:

Sorry I think I meant header_rewrite.

Brian


On Tue, Jan 24, 2017, 11:26 Brian Geffon <[hidden email]> wrote:
There is a regex_remap plugin that is what you would want, take a look in plugins/

Brian


On Tue, Jan 24, 2017, 11:25 Adi Mallikarjuna Reddy V <[hidden email]> wrote:
Is there a config that allows to change remap rule based on the incoming header?


My use case is , if I send a custom header in the request, the remap rule should be changed to different one than the default one configured.


Thanks

Adi



Reply | Threaded
Open this post in threaded view
|

Re: remap rules based on request header

Sudheer Vinukonda-2
You'd need to specify a preremap request hook (such as Read Request Header) in your rules. I think the default hook is Send Response Header.

- Sudheer 

On Jan 24, 2017, at 12:24 PM, Adi Mallikarjuna Reddy V <[hidden email]> wrote:

Ok, I tried the following one with no luck. The requests are always going to the new host without the customer header value also.

cond %{HEADER:DEV_HOST} = "dev102"
set-destination HOST dev102.abc.com [L]



my remap rule is

map / http://abc.com/ @pristine_host_hdr=1 @plugin=header_rewrite.so @pparam=my_header_rules.conf


Am I missing anything important here?


Thanks

Adi


On Tue, Jan 24, 2017 at 11:46 AM, Jeremy Payne <[hidden email]> wrote:
the lua plugin also has this functionality although may be somewhat overkill for your needs.


On Tue, Jan 24, 2017 at 1:43 PM, Adi Mallikarjuna Reddy V <[hidden email]> wrote:
So to achieve my use case, can I try something like this?

map / http://b.bar.com @plugin=header_rewrite.so @pparam=rules1.conf
and my rules1.conf has
cond %{HEADER:MY_HEADER} = "foo"
set-destination HOST mobile.bar.com [L]
This should forward the request to mobile.bar.com if the request has 'MY_HEADER' with value 'foo'.

Thanks
Adi


On Tue, Jan 24, 2017 at 11:36 AM, Brian Geffon <[hidden email]> wrote:

Sorry I think I meant header_rewrite.

Brian


On Tue, Jan 24, 2017, 11:26 Brian Geffon <[hidden email]> wrote:
There is a regex_remap plugin that is what you would want, take a look in plugins/

Brian


On Tue, Jan 24, 2017, 11:25 Adi Mallikarjuna Reddy V <[hidden email]> wrote:
Is there a config that allows to change remap rule based on the incoming header?


My use case is , if I send a custom header in the request, the remap rule should be changed to different one than the default one configured.


Thanks

Adi



Reply | Threaded
Open this post in threaded view
|

Re: remap rules based on request header

Adi Mallikarjuna Reddy V
Thanks Sudheer for the pointer. I tried the following and it looks like this condition is not working

cond %{READ_REQUEST_HDR_HOOK}

cond %{CLIENT-HEADER:DEVHOST} = dev103

set-destination HOST dev103.abc.com [L]



and 

curl -H 'DEVHOST:dev103' 'http://actual_ats_endpoint/path' -v doesnt take to that host specified.



Thanks

Adi



On Tue, Jan 24, 2017 at 12:28 PM, Sudheer Vinukonda <[hidden email]> wrote:
You'd need to specify a preremap request hook (such as Read Request Header) in your rules. I think the default hook is Send Response Header.

- Sudheer 

On Jan 24, 2017, at 12:24 PM, Adi Mallikarjuna Reddy V <[hidden email]> wrote:

Ok, I tried the following one with no luck. The requests are always going to the new host without the customer header value also.

cond %{HEADER:DEV_HOST} = "dev102"
set-destination HOST dev102.abc.com [L]



my remap rule is

map / http://abc.com/ @pristine_host_hdr=1 @plugin=header_rewrite.so @pparam=my_header_rules.conf


Am I missing anything important here?


Thanks

Adi


On Tue, Jan 24, 2017 at 11:46 AM, Jeremy Payne <[hidden email]> wrote:
the lua plugin also has this functionality although may be somewhat overkill for your needs.


On Tue, Jan 24, 2017 at 1:43 PM, Adi Mallikarjuna Reddy V <[hidden email]> wrote:
So to achieve my use case, can I try something like this?

map / http://b.bar.com @plugin=header_rewrite.so @pparam=rules1.conf
and my rules1.conf has
cond %{HEADER:MY_HEADER} = "foo"
set-destination HOST mobile.bar.com [L]
This should forward the request to mobile.bar.com if the request has 'MY_HEADER' with value 'foo'.

Thanks
Adi


On Tue, Jan 24, 2017 at 11:36 AM, Brian Geffon <[hidden email]> wrote:

Sorry I think I meant header_rewrite.

Brian


On Tue, Jan 24, 2017, 11:26 Brian Geffon <[hidden email]> wrote:
There is a regex_remap plugin that is what you would want, take a look in plugins/

Brian


On Tue, Jan 24, 2017, 11:25 Adi Mallikarjuna Reddy V <[hidden email]> wrote:
Is there a config that allows to change remap rule based on the incoming header?


My use case is , if I send a custom header in the request, the remap rule should be changed to different one than the default one configured.


Thanks

Adi




Reply | Threaded
Open this post in threaded view
|

Re: remap rules based on request header

Adi Mallikarjuna Reddy V
any help with this is greatly appreciated. Is there a debug flag to check header rewrite functionality?

On Tue, Jan 24, 2017 at 1:42 PM, Adi Mallikarjuna Reddy V <[hidden email]> wrote:
Thanks Sudheer for the pointer. I tried the following and it looks like this condition is not working

cond %{READ_REQUEST_HDR_HOOK}

cond %{CLIENT-HEADER:DEVHOST} = dev103

set-destination HOST dev103.abc.com [L]



and 

curl -H 'DEVHOST:dev103' 'http://actual_ats_endpoint/path' -v doesnt take to that host specified.



Thanks

Adi



On Tue, Jan 24, 2017 at 12:28 PM, Sudheer Vinukonda <[hidden email]> wrote:
You'd need to specify a preremap request hook (such as Read Request Header) in your rules. I think the default hook is Send Response Header.

- Sudheer 

On Jan 24, 2017, at 12:24 PM, Adi Mallikarjuna Reddy V <[hidden email]> wrote:

Ok, I tried the following one with no luck. The requests are always going to the new host without the customer header value also.

cond %{HEADER:DEV_HOST} = "dev102"
set-destination HOST dev102.abc.com [L]



my remap rule is

map / http://abc.com/ @pristine_host_hdr=1 @plugin=header_rewrite.so @pparam=my_header_rules.conf


Am I missing anything important here?


Thanks

Adi


On Tue, Jan 24, 2017 at 11:46 AM, Jeremy Payne <[hidden email]> wrote:
the lua plugin also has this functionality although may be somewhat overkill for your needs.


On Tue, Jan 24, 2017 at 1:43 PM, Adi Mallikarjuna Reddy V <[hidden email]> wrote:
So to achieve my use case, can I try something like this?

map / http://b.bar.com @plugin=header_rewrite.so @pparam=rules1.conf
and my rules1.conf has
cond %{HEADER:MY_HEADER} = "foo"
set-destination HOST mobile.bar.com [L]
This should forward the request to mobile.bar.com if the request has 'MY_HEADER' with value 'foo'.

Thanks
Adi


On Tue, Jan 24, 2017 at 11:36 AM, Brian Geffon <[hidden email]> wrote:

Sorry I think I meant header_rewrite.

Brian


On Tue, Jan 24, 2017, 11:26 Brian Geffon <[hidden email]> wrote:
There is a regex_remap plugin that is what you would want, take a look in plugins/

Brian


On Tue, Jan 24, 2017, 11:25 Adi Mallikarjuna Reddy V <[hidden email]> wrote:
Is there a config that allows to change remap rule based on the incoming header?


My use case is , if I send a custom header in the request, the remap rule should be changed to different one than the default one configured.


Thanks

Adi





Reply | Threaded
Open this post in threaded view
|

Re: remap rules based on request header

Jeremy Payne

On Wed, Jan 25, 2017 at 12:33 PM, Adi Mallikarjuna Reddy V <[hidden email]> wrote:
any help with this is greatly appreciated. Is there a debug flag to check header rewrite functionality?

On Tue, Jan 24, 2017 at 1:42 PM, Adi Mallikarjuna Reddy V <[hidden email]> wrote:
Thanks Sudheer for the pointer. I tried the following and it looks like this condition is not working

cond %{READ_REQUEST_HDR_HOOK}

cond %{CLIENT-HEADER:DEVHOST} = dev103

set-destination HOST dev103.abc.com [L]



and 

curl -H 'DEVHOST:dev103' 'http://actual_ats_endpoint/path' -v doesnt take to that host specified.



Thanks

Adi



On Tue, Jan 24, 2017 at 12:28 PM, Sudheer Vinukonda <[hidden email]> wrote:
You'd need to specify a preremap request hook (such as Read Request Header) in your rules. I think the default hook is Send Response Header.

- Sudheer 

On Jan 24, 2017, at 12:24 PM, Adi Mallikarjuna Reddy V <[hidden email]> wrote:

Ok, I tried the following one with no luck. The requests are always going to the new host without the customer header value also.

cond %{HEADER:DEV_HOST} = "dev102"
set-destination HOST dev102.abc.com [L]



my remap rule is

map / http://abc.com/ @pristine_host_hdr=1 @plugin=header_rewrite.so @pparam=my_header_rules.conf


Am I missing anything important here?


Thanks

Adi


On Tue, Jan 24, 2017 at 11:46 AM, Jeremy Payne <[hidden email]> wrote:
the lua plugin also has this functionality although may be somewhat overkill for your needs.


On Tue, Jan 24, 2017 at 1:43 PM, Adi Mallikarjuna Reddy V <[hidden email]> wrote:
So to achieve my use case, can I try something like this?

map / http://b.bar.com @plugin=header_rewrite.so @pparam=rules1.conf
and my rules1.conf has
cond %{HEADER:MY_HEADER} = "foo"
set-destination HOST mobile.bar.com [L]
This should forward the request to mobile.bar.com if the request has 'MY_HEADER' with value 'foo'.

Thanks
Adi


On Tue, Jan 24, 2017 at 11:36 AM, Brian Geffon <[hidden email]> wrote:

Sorry I think I meant header_rewrite.

Brian


On Tue, Jan 24, 2017, 11:26 Brian Geffon <[hidden email]> wrote:
There is a regex_remap plugin that is what you would want, take a look in plugins/

Brian


On Tue, Jan 24, 2017, 11:25 Adi Mallikarjuna Reddy V <[hidden email]> wrote:
Is there a config that allows to change remap rule based on the incoming header?


My use case is , if I send a custom header in the request, the remap rule should be changed to different one than the default one configured.


Thanks

Adi






Reply | Threaded
Open this post in threaded view
|

Re: remap rules based on request header

Adi Mallikarjuna Reddy V
For this to work, do I have to install Lua runtime on my host?

On Wed, Jan 25, 2017 at 10:49 AM, Jeremy Payne <[hidden email]> wrote:

On Wed, Jan 25, 2017 at 12:33 PM, Adi Mallikarjuna Reddy V <[hidden email]> wrote:
any help with this is greatly appreciated. Is there a debug flag to check header rewrite functionality?

On Tue, Jan 24, 2017 at 1:42 PM, Adi Mallikarjuna Reddy V <[hidden email]> wrote:
Thanks Sudheer for the pointer. I tried the following and it looks like this condition is not working

cond %{READ_REQUEST_HDR_HOOK}

cond %{CLIENT-HEADER:DEVHOST} = dev103

set-destination HOST dev103.abc.com [L]



and 

curl -H 'DEVHOST:dev103' 'http://actual_ats_endpoint/path' -v doesnt take to that host specified.



Thanks

Adi



On Tue, Jan 24, 2017 at 12:28 PM, Sudheer Vinukonda <[hidden email]> wrote:
You'd need to specify a preremap request hook (such as Read Request Header) in your rules. I think the default hook is Send Response Header.

- Sudheer 

On Jan 24, 2017, at 12:24 PM, Adi Mallikarjuna Reddy V <[hidden email]> wrote:

Ok, I tried the following one with no luck. The requests are always going to the new host without the customer header value also.

cond %{HEADER:DEV_HOST} = "dev102"
set-destination HOST dev102.abc.com [L]



my remap rule is

map / http://abc.com/ @pristine_host_hdr=1 @plugin=header_rewrite.so @pparam=my_header_rules.conf


Am I missing anything important here?


Thanks

Adi


On Tue, Jan 24, 2017 at 11:46 AM, Jeremy Payne <[hidden email]> wrote:
the lua plugin also has this functionality although may be somewhat overkill for your needs.


On Tue, Jan 24, 2017 at 1:43 PM, Adi Mallikarjuna Reddy V <[hidden email]> wrote:
So to achieve my use case, can I try something like this?

map / http://b.bar.com @plugin=header_rewrite.so @pparam=rules1.conf
and my rules1.conf has
cond %{HEADER:MY_HEADER} = "foo"
set-destination HOST mobile.bar.com [L]
This should forward the request to mobile.bar.com if the request has 'MY_HEADER' with value 'foo'.

Thanks
Adi


On Tue, Jan 24, 2017 at 11:36 AM, Brian Geffon <[hidden email]> wrote:

Sorry I think I meant header_rewrite.

Brian


On Tue, Jan 24, 2017, 11:26 Brian Geffon <[hidden email]> wrote:
There is a regex_remap plugin that is what you would want, take a look in plugins/

Brian


On Tue, Jan 24, 2017, 11:25 Adi Mallikarjuna Reddy V <[hidden email]> wrote:
Is there a config that allows to change remap rule based on the incoming header?


My use case is , if I send a custom header in the request, the remap rule should be changed to different one than the default one configured.


Thanks

Adi







Reply | Threaded
Open this post in threaded view
|

Re: remap rules based on request header

Shu Kit Chan
No, you don't need lua runtime on your host. Just compile the
experimental plugin and that's it. More information here -
https://docs.trafficserver.apache.org/en/latest/admin-guide/plugins/ts_lua.en.html

Thanks.

On Wed, Jan 25, 2017 at 5:10 PM, Adi Mallikarjuna Reddy V
<[hidden email]> wrote:

> For this to work, do I have to install Lua runtime on my host?
>
> On Wed, Jan 25, 2017 at 10:49 AM, Jeremy Payne <[hidden email]> wrote:
>>
>> i use the lua plugin to change origin host based on certain conditions.
>>
>>
>> https://docs.trafficserver.apache.org/en/latest/admin-guide/plugins/ts_lua.en.html#ts-client-request-set-url-host
>>
>> On Wed, Jan 25, 2017 at 12:33 PM, Adi Mallikarjuna Reddy V
>> <[hidden email]> wrote:
>>>
>>> any help with this is greatly appreciated. Is there a debug flag to check
>>> header rewrite functionality?
>>>
>>> On Tue, Jan 24, 2017 at 1:42 PM, Adi Mallikarjuna Reddy V
>>> <[hidden email]> wrote:
>>>>
>>>> Thanks Sudheer for the pointer. I tried the following and it looks like
>>>> this condition is not working
>>>>
>>>> cond %{READ_REQUEST_HDR_HOOK}
>>>>
>>>> cond %{CLIENT-HEADER:DEVHOST} = dev103
>>>>
>>>> set-destination HOST dev103.abc.com [L]
>>>>
>>>>
>>>>
>>>> and
>>>>
>>>> curl -H 'DEVHOST:dev103' 'http://actual_ats_endpoint/path' -v doesnt
>>>> take to that host specified.
>>>>
>>>>
>>>>
>>>> Thanks
>>>>
>>>> Adi
>>>>
>>>>
>>>>
>>>> On Tue, Jan 24, 2017 at 12:28 PM, Sudheer Vinukonda
>>>> <[hidden email]> wrote:
>>>>>
>>>>> You'd need to specify a preremap request hook (such as Read Request
>>>>> Header) in your rules. I think the default hook is Send Response Header.
>>>>>
>>>>> - Sudheer
>>>>>
>>>>> On Jan 24, 2017, at 12:24 PM, Adi Mallikarjuna Reddy V
>>>>> <[hidden email]> wrote:
>>>>>
>>>>> Ok, I tried the following one with no luck. The requests are always
>>>>> going to the new host without the customer header value also.
>>>>>
>>>>> cond %{HEADER:DEV_HOST} = "dev102"
>>>>> set-destination HOST dev102.abc.com [L]
>>>>>
>>>>>
>>>>> my remap rule is
>>>>>
>>>>> map / http://abc.com/ @pristine_host_hdr=1 @plugin=header_rewrite.so
>>>>> @pparam=my_header_rules.conf
>>>>>
>>>>>
>>>>> Am I missing anything important here?
>>>>>
>>>>>
>>>>> Thanks
>>>>>
>>>>> Adi
>>>>>
>>>>>
>>>>> On Tue, Jan 24, 2017 at 11:46 AM, Jeremy Payne <[hidden email]>
>>>>> wrote:
>>>>>>
>>>>>> the lua plugin also has this functionality although may be somewhat
>>>>>> overkill for your needs.
>>>>>>
>>>>>>
>>>>>> On Tue, Jan 24, 2017 at 1:43 PM, Adi Mallikarjuna Reddy V
>>>>>> <[hidden email]> wrote:
>>>>>>>
>>>>>>> So to achieve my use case, can I try something like this?
>>>>>>>
>>>>>>> map / http://b.bar.com @plugin=header_rewrite.so @pparam=rules1.conf
>>>>>>>
>>>>>>> and my rules1.conf has
>>>>>>>
>>>>>>> cond %{HEADER:MY_HEADER} = "foo"
>>>>>>> set-destination HOST mobile.bar.com [L]
>>>>>>>
>>>>>>> This should forward the request to mobile.bar.com if the request has
>>>>>>> 'MY_HEADER' with value 'foo'.
>>>>>>>
>>>>>>>
>>>>>>> Thanks
>>>>>>>
>>>>>>> Adi
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Tue, Jan 24, 2017 at 11:36 AM, Brian Geffon
>>>>>>> <[hidden email]> wrote:
>>>>>>>>
>>>>>>>> Sorry I think I meant header_rewrite.
>>>>>>>>
>>>>>>>> Brian
>>>>>>>>
>>>>>>>>
>>>>>>>> On Tue, Jan 24, 2017, 11:26 Brian Geffon <[hidden email]>
>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>> There is a regex_remap plugin that is what you would want, take a
>>>>>>>>> look in plugins/
>>>>>>>>>
>>>>>>>>> Brian
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Tue, Jan 24, 2017, 11:25 Adi Mallikarjuna Reddy V
>>>>>>>>> <[hidden email]> wrote:
>>>>>>>>>>
>>>>>>>>>> Is there a config that allows to change remap rule based on the
>>>>>>>>>> incoming header?
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> My use case is , if I send a custom header in the request, the
>>>>>>>>>> remap rule should be changed to different one than the default one
>>>>>>>>>> configured.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Thanks
>>>>>>>>>>
>>>>>>>>>> Adi
>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: remap rules based on request header

Adi Mallikarjuna Reddy V

After adding lua plugin with remap rule in remap.config and writing some sample code mentioned in https://docs.trafficserver.apache.org/en/latest/admin-guide/plugins/ts_lua.en.html#ts-client-request-set-url-host I see the following error in traffic server.


[May  8 08:57:44.851] Server {0x2aeb0862c2c0} WARNING: Failed to create new instance for plugin libtslua.so (not a TS_SUCCESS return)

[May  8 08:57:44.851] Server {0x2aeb0862c2c0} WARNING: Could not add rule at line #25; Aborting!

[May  8 08:57:44.851] Server {0x2aeb0862c2c0} WARNING: [ReverseProxy] Can't create new remap instance for plugin "libtslua.so" - [TSRemapNewInstance] ts_lua_add_module failed at line 25

[May  8 08:57:44.852] Server {0x2aeb0862c2c0} WARNING: something failed during BuildTable() -- check your remap plugins!

[May  8 08:57:44.852] Server {0x2aeb0862c2c0} WARNING: Can not load the remap table, exiting out!


Is there any thing that I am missing out?


Thanks

Adi



On Sun, Feb 5, 2017 at 11:39 PM, Shu Kit Chan <[hidden email]> wrote:
No, you don't need lua runtime on your host. Just compile the
experimental plugin and that's it. More information here -
https://docs.trafficserver.apache.org/en/latest/admin-guide/plugins/ts_lua.en.html

Thanks.

On Wed, Jan 25, 2017 at 5:10 PM, Adi Mallikarjuna Reddy V
<[hidden email]> wrote:
> For this to work, do I have to install Lua runtime on my host?
>
> On Wed, Jan 25, 2017 at 10:49 AM, Jeremy Payne <[hidden email]> wrote:
>>
>> i use the lua plugin to change origin host based on certain conditions.
>>
>>
>> https://docs.trafficserver.apache.org/en/latest/admin-guide/plugins/ts_lua.en.html#ts-client-request-set-url-host
>>
>> On Wed, Jan 25, 2017 at 12:33 PM, Adi Mallikarjuna Reddy V
>> <[hidden email]> wrote:
>>>
>>> any help with this is greatly appreciated. Is there a debug flag to check
>>> header rewrite functionality?
>>>
>>> On Tue, Jan 24, 2017 at 1:42 PM, Adi Mallikarjuna Reddy V
>>> <[hidden email]> wrote:
>>>>
>>>> Thanks Sudheer for the pointer. I tried the following and it looks like
>>>> this condition is not working
>>>>
>>>> cond %{READ_REQUEST_HDR_HOOK}
>>>>
>>>> cond %{CLIENT-HEADER:DEVHOST} = dev103
>>>>
>>>> set-destination HOST dev103.abc.com [L]
>>>>
>>>>
>>>>
>>>> and
>>>>
>>>> curl -H 'DEVHOST:dev103' 'http://actual_ats_endpoint/path' -v doesnt
>>>> take to that host specified.
>>>>
>>>>
>>>>
>>>> Thanks
>>>>
>>>> Adi
>>>>
>>>>
>>>>
>>>> On Tue, Jan 24, 2017 at 12:28 PM, Sudheer Vinukonda
>>>> <[hidden email]> wrote:
>>>>>
>>>>> You'd need to specify a preremap request hook (such as Read Request
>>>>> Header) in your rules. I think the default hook is Send Response Header.
>>>>>
>>>>> - Sudheer
>>>>>
>>>>> On Jan 24, 2017, at 12:24 PM, Adi Mallikarjuna Reddy V
>>>>> <[hidden email]> wrote:
>>>>>
>>>>> Ok, I tried the following one with no luck. The requests are always
>>>>> going to the new host without the customer header value also.
>>>>>
>>>>> cond %{HEADER:DEV_HOST} = "dev102"
>>>>> set-destination HOST dev102.abc.com [L]
>>>>>
>>>>>
>>>>> my remap rule is
>>>>>
>>>>> map / http://abc.com/ @pristine_host_hdr=1 @plugin=header_rewrite.so
>>>>> @pparam=my_header_rules.conf
>>>>>
>>>>>
>>>>> Am I missing anything important here?
>>>>>
>>>>>
>>>>> Thanks
>>>>>
>>>>> Adi
>>>>>
>>>>>
>>>>> On Tue, Jan 24, 2017 at 11:46 AM, Jeremy Payne <[hidden email]>
>>>>> wrote:
>>>>>>
>>>>>> the lua plugin also has this functionality although may be somewhat
>>>>>> overkill for your needs.
>>>>>>
>>>>>>
>>>>>> On Tue, Jan 24, 2017 at 1:43 PM, Adi Mallikarjuna Reddy V
>>>>>> <[hidden email]> wrote:
>>>>>>>
>>>>>>> So to achieve my use case, can I try something like this?
>>>>>>>
>>>>>>> map / http://b.bar.com @plugin=header_rewrite.so @pparam=rules1.conf
>>>>>>>
>>>>>>> and my rules1.conf has
>>>>>>>
>>>>>>> cond %{HEADER:MY_HEADER} = "foo"
>>>>>>> set-destination HOST mobile.bar.com [L]
>>>>>>>
>>>>>>> This should forward the request to mobile.bar.com if the request has
>>>>>>> 'MY_HEADER' with value 'foo'.
>>>>>>>
>>>>>>>
>>>>>>> Thanks
>>>>>>>
>>>>>>> Adi
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Tue, Jan 24, 2017 at 11:36 AM, Brian Geffon
>>>>>>> <[hidden email]> wrote:
>>>>>>>>
>>>>>>>> Sorry I think I meant header_rewrite.
>>>>>>>>
>>>>>>>> Brian
>>>>>>>>
>>>>>>>>
>>>>>>>> On Tue, Jan 24, 2017, 11:26 Brian Geffon <[hidden email]>
>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>> There is a regex_remap plugin that is what you would want, take a
>>>>>>>>> look in plugins/
>>>>>>>>>
>>>>>>>>> Brian
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Tue, Jan 24, 2017, 11:25 Adi Mallikarjuna Reddy V
>>>>>>>>> <[hidden email]> wrote:
>>>>>>>>>>
>>>>>>>>>> Is there a config that allows to change remap rule based on the
>>>>>>>>>> incoming header?
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> My use case is , if I send a custom header in the request, the
>>>>>>>>>> remap rule should be changed to different one than the default one
>>>>>>>>>> configured.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Thanks
>>>>>>>>>>
>>>>>>>>>> Adi
>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>

Reply | Threaded
Open this post in threaded view
|

Re: remap rules based on request header

Jeremy Payne
verify your remap rules and/or lua scripts to ensure they are syntactically correct.

also enable debug.. .may provide further insight..

can you also share your remap file and corresponding lua scripts ?




On Mon, May 8, 2017 at 11:00 AM, Adi Mallikarjuna Reddy V <[hidden email]> wrote:

After adding lua plugin with remap rule in remap.config and writing some sample code mentioned in https://docs.trafficserver.apache.org/en/latest/admin-guide/plugins/ts_lua.en.html#ts-client-request-set-url-host I see the following error in traffic server.


[May  8 08:57:44.851] Server {0x2aeb0862c2c0} WARNING: Failed to create new instance for plugin libtslua.so (not a TS_SUCCESS return)

[May  8 08:57:44.851] Server {0x2aeb0862c2c0} WARNING: Could not add rule at line #25; Aborting!

[May  8 08:57:44.851] Server {0x2aeb0862c2c0} WARNING: [ReverseProxy] Can't create new remap instance for plugin "libtslua.so" - [TSRemapNewInstance] ts_lua_add_module failed at line 25

[May  8 08:57:44.852] Server {0x2aeb0862c2c0} WARNING: something failed during BuildTable() -- check your remap plugins!

[May  8 08:57:44.852] Server {0x2aeb0862c2c0} WARNING: Can not load the remap table, exiting out!


Is there any thing that I am missing out?


Thanks

Adi



On Sun, Feb 5, 2017 at 11:39 PM, Shu Kit Chan <[hidden email]> wrote:
No, you don't need lua runtime on your host. Just compile the
experimental plugin and that's it. More information here -
https://docs.trafficserver.apache.org/en/latest/admin-guide/plugins/ts_lua.en.html

Thanks.

On Wed, Jan 25, 2017 at 5:10 PM, Adi Mallikarjuna Reddy V
<[hidden email]> wrote:
> For this to work, do I have to install Lua runtime on my host?
>
> On Wed, Jan 25, 2017 at 10:49 AM, Jeremy Payne <[hidden email]> wrote:
>>
>> i use the lua plugin to change origin host based on certain conditions.
>>
>>
>> https://docs.trafficserver.apache.org/en/latest/admin-guide/plugins/ts_lua.en.html#ts-client-request-set-url-host
>>
>> On Wed, Jan 25, 2017 at 12:33 PM, Adi Mallikarjuna Reddy V
>> <[hidden email]> wrote:
>>>
>>> any help with this is greatly appreciated. Is there a debug flag to check
>>> header rewrite functionality?
>>>
>>> On Tue, Jan 24, 2017 at 1:42 PM, Adi Mallikarjuna Reddy V
>>> <[hidden email]> wrote:
>>>>
>>>> Thanks Sudheer for the pointer. I tried the following and it looks like
>>>> this condition is not working
>>>>
>>>> cond %{READ_REQUEST_HDR_HOOK}
>>>>
>>>> cond %{CLIENT-HEADER:DEVHOST} = dev103
>>>>
>>>> set-destination HOST dev103.abc.com [L]
>>>>
>>>>
>>>>
>>>> and
>>>>
>>>> curl -H 'DEVHOST:dev103' 'http://actual_ats_endpoint/path' -v doesnt
>>>> take to that host specified.
>>>>
>>>>
>>>>
>>>> Thanks
>>>>
>>>> Adi
>>>>
>>>>
>>>>
>>>> On Tue, Jan 24, 2017 at 12:28 PM, Sudheer Vinukonda
>>>> <[hidden email]> wrote:
>>>>>
>>>>> You'd need to specify a preremap request hook (such as Read Request
>>>>> Header) in your rules. I think the default hook is Send Response Header.
>>>>>
>>>>> - Sudheer
>>>>>
>>>>> On Jan 24, 2017, at 12:24 PM, Adi Mallikarjuna Reddy V
>>>>> <[hidden email]> wrote:
>>>>>
>>>>> Ok, I tried the following one with no luck. The requests are always
>>>>> going to the new host without the customer header value also.
>>>>>
>>>>> cond %{HEADER:DEV_HOST} = "dev102"
>>>>> set-destination HOST dev102.abc.com [L]
>>>>>
>>>>>
>>>>> my remap rule is
>>>>>
>>>>> map / http://abc.com/ @pristine_host_hdr=1 @plugin=header_rewrite.so
>>>>> @pparam=my_header_rules.conf
>>>>>
>>>>>
>>>>> Am I missing anything important here?
>>>>>
>>>>>
>>>>> Thanks
>>>>>
>>>>> Adi
>>>>>
>>>>>
>>>>> On Tue, Jan 24, 2017 at 11:46 AM, Jeremy Payne <[hidden email]>
>>>>> wrote:
>>>>>>
>>>>>> the lua plugin also has this functionality although may be somewhat
>>>>>> overkill for your needs.
>>>>>>
>>>>>>
>>>>>> On Tue, Jan 24, 2017 at 1:43 PM, Adi Mallikarjuna Reddy V
>>>>>> <[hidden email]> wrote:
>>>>>>>
>>>>>>> So to achieve my use case, can I try something like this?
>>>>>>>
>>>>>>> map / http://b.bar.com @plugin=header_rewrite.so @pparam=rules1.conf
>>>>>>>
>>>>>>> and my rules1.conf has
>>>>>>>
>>>>>>> cond %{HEADER:MY_HEADER} = "foo"
>>>>>>> set-destination HOST mobile.bar.com [L]
>>>>>>>
>>>>>>> This should forward the request to mobile.bar.com if the request has
>>>>>>> 'MY_HEADER' with value 'foo'.
>>>>>>>
>>>>>>>
>>>>>>> Thanks
>>>>>>>
>>>>>>> Adi
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Tue, Jan 24, 2017 at 11:36 AM, Brian Geffon
>>>>>>> <[hidden email]> wrote:
>>>>>>>>
>>>>>>>> Sorry I think I meant header_rewrite.
>>>>>>>>
>>>>>>>> Brian
>>>>>>>>
>>>>>>>>
>>>>>>>> On Tue, Jan 24, 2017, 11:26 Brian Geffon <[hidden email]>
>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>> There is a regex_remap plugin that is what you would want, take a
>>>>>>>>> look in plugins/
>>>>>>>>>
>>>>>>>>> Brian
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Tue, Jan 24, 2017, 11:25 Adi Mallikarjuna Reddy V
>>>>>>>>> <[hidden email]> wrote:
>>>>>>>>>>
>>>>>>>>>> Is there a config that allows to change remap rule based on the
>>>>>>>>>> incoming header?
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> My use case is , if I send a custom header in the request, the
>>>>>>>>>> remap rule should be changed to different one than the default one
>>>>>>>>>> configured.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Thanks
>>>>>>>>>>
>>>>>>>>>> Adi
>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>


Reply | Threaded
Open this post in threaded view
|

Re: remap rules based on request header

Adi Mallikarjuna Reddy V
remap rule

map /random_path http://dummy_destination.com/ @pristine_host_hdr=1 @plugin=libtslua.so @pparam=lua_remap.lua


script - lua_remap.lua


function do_remap()

    ts.client_request.set_url_host('actual_destination.com')

    ts.client_request.set_url_port(80)

    ts.client_request.set_url_scheme('http')

    return TS_LUA_REMAP_DID_REMAP

end

No extra info with debug tag ts_lua enabled, as this seems to be failing to parse the remap config itself.


Thanks

Adi


On Mon, May 8, 2017 at 9:13 AM, Jeremy Payne <[hidden email]> wrote:
verify your remap rules and/or lua scripts to ensure they are syntactically correct.

also enable debug.. .may provide further insight..

can you also share your remap file and corresponding lua scripts ?




On Mon, May 8, 2017 at 11:00 AM, Adi Mallikarjuna Reddy V <[hidden email]> wrote:

After adding lua plugin with remap rule in remap.config and writing some sample code mentioned in https://docs.trafficserver.apache.org/en/latest/admin-guide/plugins/ts_lua.en.html#ts-client-request-set-url-host I see the following error in traffic server.


[May  8 08:57:44.851] Server {0x2aeb0862c2c0} WARNING: Failed to create new instance for plugin libtslua.so (not a TS_SUCCESS return)

[May  8 08:57:44.851] Server {0x2aeb0862c2c0} WARNING: Could not add rule at line #25; Aborting!

[May  8 08:57:44.851] Server {0x2aeb0862c2c0} WARNING: [ReverseProxy] Can't create new remap instance for plugin "libtslua.so" - [TSRemapNewInstance] ts_lua_add_module failed at line 25

[May  8 08:57:44.852] Server {0x2aeb0862c2c0} WARNING: something failed during BuildTable() -- check your remap plugins!

[May  8 08:57:44.852] Server {0x2aeb0862c2c0} WARNING: Can not load the remap table, exiting out!


Is there any thing that I am missing out?


Thanks

Adi



On Sun, Feb 5, 2017 at 11:39 PM, Shu Kit Chan <[hidden email]> wrote:
No, you don't need lua runtime on your host. Just compile the
experimental plugin and that's it. More information here -
https://docs.trafficserver.apache.org/en/latest/admin-guide/plugins/ts_lua.en.html

Thanks.

On Wed, Jan 25, 2017 at 5:10 PM, Adi Mallikarjuna Reddy V
<[hidden email]> wrote:
> For this to work, do I have to install Lua runtime on my host?
>
> On Wed, Jan 25, 2017 at 10:49 AM, Jeremy Payne <[hidden email]> wrote:
>>
>> i use the lua plugin to change origin host based on certain conditions.
>>
>>
>> https://docs.trafficserver.apache.org/en/latest/admin-guide/plugins/ts_lua.en.html#ts-client-request-set-url-host
>>
>> On Wed, Jan 25, 2017 at 12:33 PM, Adi Mallikarjuna Reddy V
>> <[hidden email]> wrote:
>>>
>>> any help with this is greatly appreciated. Is there a debug flag to check
>>> header rewrite functionality?
>>>
>>> On Tue, Jan 24, 2017 at 1:42 PM, Adi Mallikarjuna Reddy V
>>> <[hidden email]> wrote:
>>>>
>>>> Thanks Sudheer for the pointer. I tried the following and it looks like
>>>> this condition is not working
>>>>
>>>> cond %{READ_REQUEST_HDR_HOOK}
>>>>
>>>> cond %{CLIENT-HEADER:DEVHOST} = dev103
>>>>
>>>> set-destination HOST dev103.abc.com [L]
>>>>
>>>>
>>>>
>>>> and
>>>>
>>>> curl -H 'DEVHOST:dev103' 'http://actual_ats_endpoint/path' -v doesnt
>>>> take to that host specified.
>>>>
>>>>
>>>>
>>>> Thanks
>>>>
>>>> Adi
>>>>
>>>>
>>>>
>>>> On Tue, Jan 24, 2017 at 12:28 PM, Sudheer Vinukonda
>>>> <[hidden email]> wrote:
>>>>>
>>>>> You'd need to specify a preremap request hook (such as Read Request
>>>>> Header) in your rules. I think the default hook is Send Response Header.
>>>>>
>>>>> - Sudheer
>>>>>
>>>>> On Jan 24, 2017, at 12:24 PM, Adi Mallikarjuna Reddy V
>>>>> <[hidden email]> wrote:
>>>>>
>>>>> Ok, I tried the following one with no luck. The requests are always
>>>>> going to the new host without the customer header value also.
>>>>>
>>>>> cond %{HEADER:DEV_HOST} = "dev102"
>>>>> set-destination HOST dev102.abc.com [L]
>>>>>
>>>>>
>>>>> my remap rule is
>>>>>
>>>>> map / http://abc.com/ @pristine_host_hdr=1 @plugin=header_rewrite.so
>>>>> @pparam=my_header_rules.conf
>>>>>
>>>>>
>>>>> Am I missing anything important here?
>>>>>
>>>>>
>>>>> Thanks
>>>>>
>>>>> Adi
>>>>>
>>>>>
>>>>> On Tue, Jan 24, 2017 at 11:46 AM, Jeremy Payne <[hidden email]>
>>>>> wrote:
>>>>>>
>>>>>> the lua plugin also has this functionality although may be somewhat
>>>>>> overkill for your needs.
>>>>>>
>>>>>>
>>>>>> On Tue, Jan 24, 2017 at 1:43 PM, Adi Mallikarjuna Reddy V
>>>>>> <[hidden email]> wrote:
>>>>>>>
>>>>>>> So to achieve my use case, can I try something like this?
>>>>>>>
>>>>>>> map / http://b.bar.com @plugin=header_rewrite.so @pparam=rules1.conf
>>>>>>>
>>>>>>> and my rules1.conf has
>>>>>>>
>>>>>>> cond %{HEADER:MY_HEADER} = "foo"
>>>>>>> set-destination HOST mobile.bar.com [L]
>>>>>>>
>>>>>>> This should forward the request to mobile.bar.com if the request has
>>>>>>> 'MY_HEADER' with value 'foo'.
>>>>>>>
>>>>>>>
>>>>>>> Thanks
>>>>>>>
>>>>>>> Adi
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Tue, Jan 24, 2017 at 11:36 AM, Brian Geffon
>>>>>>> <[hidden email]> wrote:
>>>>>>>>
>>>>>>>> Sorry I think I meant header_rewrite.
>>>>>>>>
>>>>>>>> Brian
>>>>>>>>
>>>>>>>>
>>>>>>>> On Tue, Jan 24, 2017, 11:26 Brian Geffon <[hidden email]>
>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>> There is a regex_remap plugin that is what you would want, take a
>>>>>>>>> look in plugins/
>>>>>>>>>
>>>>>>>>> Brian
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Tue, Jan 24, 2017, 11:25 Adi Mallikarjuna Reddy V
>>>>>>>>> <[hidden email]> wrote:
>>>>>>>>>>
>>>>>>>>>> Is there a config that allows to change remap rule based on the
>>>>>>>>>> incoming header?
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> My use case is , if I send a custom header in the request, the
>>>>>>>>>> remap rule should be changed to different one than the default one
>>>>>>>>>> configured.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Thanks
>>>>>>>>>>
>>>>>>>>>> Adi
>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>



Reply | Threaded
Open this post in threaded view
|

Re: remap rules based on request header

Jeremy Payne
remove this 'param'

@pristine_host_hdr=1

place this in your lua script, to enable pristine.. 

ts.http.config_int_set(TS_LUA_CONFIG_URL_REMAP_PRISTINE_HOST_HDR, 1)



On Mon, May 8, 2017 at 11:18 AM, Adi Mallikarjuna Reddy V <[hidden email]> wrote:
remap rule

map /random_path http://dummy_destination.com/ @pristine_host_hdr=1 @plugin=libtslua.so @pparam=lua_remap.lua


script - lua_remap.lua


function do_remap()

    ts.client_request.set_url_host('actual_destination.com')

    ts.client_request.set_url_port(80)

    ts.client_request.set_url_scheme('http')

    return TS_LUA_REMAP_DID_REMAP

end

No extra info with debug tag ts_lua enabled, as this seems to be failing to parse the remap config itself.


Thanks

Adi


On Mon, May 8, 2017 at 9:13 AM, Jeremy Payne <[hidden email]> wrote:
verify your remap rules and/or lua scripts to ensure they are syntactically correct.

also enable debug.. .may provide further insight..

can you also share your remap file and corresponding lua scripts ?




On Mon, May 8, 2017 at 11:00 AM, Adi Mallikarjuna Reddy V <[hidden email]> wrote:

After adding lua plugin with remap rule in remap.config and writing some sample code mentioned in https://docs.trafficserver.apache.org/en/latest/admin-guide/plugins/ts_lua.en.html#ts-client-request-set-url-host I see the following error in traffic server.


[May  8 08:57:44.851] Server {0x2aeb0862c2c0} WARNING: Failed to create new instance for plugin libtslua.so (not a TS_SUCCESS return)

[May  8 08:57:44.851] Server {0x2aeb0862c2c0} WARNING: Could not add rule at line #25; Aborting!

[May  8 08:57:44.851] Server {0x2aeb0862c2c0} WARNING: [ReverseProxy] Can't create new remap instance for plugin "libtslua.so" - [TSRemapNewInstance] ts_lua_add_module failed at line 25

[May  8 08:57:44.852] Server {0x2aeb0862c2c0} WARNING: something failed during BuildTable() -- check your remap plugins!

[May  8 08:57:44.852] Server {0x2aeb0862c2c0} WARNING: Can not load the remap table, exiting out!


Is there any thing that I am missing out?


Thanks

Adi



On Sun, Feb 5, 2017 at 11:39 PM, Shu Kit Chan <[hidden email]> wrote:
No, you don't need lua runtime on your host. Just compile the
experimental plugin and that's it. More information here -
https://docs.trafficserver.apache.org/en/latest/admin-guide/plugins/ts_lua.en.html

Thanks.

On Wed, Jan 25, 2017 at 5:10 PM, Adi Mallikarjuna Reddy V
<[hidden email]> wrote:
> For this to work, do I have to install Lua runtime on my host?
>
> On Wed, Jan 25, 2017 at 10:49 AM, Jeremy Payne <[hidden email]> wrote:
>>
>> i use the lua plugin to change origin host based on certain conditions.
>>
>>
>> https://docs.trafficserver.apache.org/en/latest/admin-guide/plugins/ts_lua.en.html#ts-client-request-set-url-host
>>
>> On Wed, Jan 25, 2017 at 12:33 PM, Adi Mallikarjuna Reddy V
>> <[hidden email]> wrote:
>>>
>>> any help with this is greatly appreciated. Is there a debug flag to check
>>> header rewrite functionality?
>>>
>>> On Tue, Jan 24, 2017 at 1:42 PM, Adi Mallikarjuna Reddy V
>>> <[hidden email]> wrote:
>>>>
>>>> Thanks Sudheer for the pointer. I tried the following and it looks like
>>>> this condition is not working
>>>>
>>>> cond %{READ_REQUEST_HDR_HOOK}
>>>>
>>>> cond %{CLIENT-HEADER:DEVHOST} = dev103
>>>>
>>>> set-destination HOST dev103.abc.com [L]
>>>>
>>>>
>>>>
>>>> and
>>>>
>>>> curl -H 'DEVHOST:dev103' 'http://actual_ats_endpoint/path' -v doesnt
>>>> take to that host specified.
>>>>
>>>>
>>>>
>>>> Thanks
>>>>
>>>> Adi
>>>>
>>>>
>>>>
>>>> On Tue, Jan 24, 2017 at 12:28 PM, Sudheer Vinukonda
>>>> <[hidden email]> wrote:
>>>>>
>>>>> You'd need to specify a preremap request hook (such as Read Request
>>>>> Header) in your rules. I think the default hook is Send Response Header.
>>>>>
>>>>> - Sudheer
>>>>>
>>>>> On Jan 24, 2017, at 12:24 PM, Adi Mallikarjuna Reddy V
>>>>> <[hidden email]> wrote:
>>>>>
>>>>> Ok, I tried the following one with no luck. The requests are always
>>>>> going to the new host without the customer header value also.
>>>>>
>>>>> cond %{HEADER:DEV_HOST} = "dev102"
>>>>> set-destination HOST dev102.abc.com [L]
>>>>>
>>>>>
>>>>> my remap rule is
>>>>>
>>>>> map / http://abc.com/ @pristine_host_hdr=1 @plugin=header_rewrite.so
>>>>> @pparam=my_header_rules.conf
>>>>>
>>>>>
>>>>> Am I missing anything important here?
>>>>>
>>>>>
>>>>> Thanks
>>>>>
>>>>> Adi
>>>>>
>>>>>
>>>>> On Tue, Jan 24, 2017 at 11:46 AM, Jeremy Payne <[hidden email]>
>>>>> wrote:
>>>>>>
>>>>>> the lua plugin also has this functionality although may be somewhat
>>>>>> overkill for your needs.
>>>>>>
>>>>>>
>>>>>> On Tue, Jan 24, 2017 at 1:43 PM, Adi Mallikarjuna Reddy V
>>>>>> <[hidden email]> wrote:
>>>>>>>
>>>>>>> So to achieve my use case, can I try something like this?
>>>>>>>
>>>>>>> map / http://b.bar.com @plugin=header_rewrite.so @pparam=rules1.conf
>>>>>>>
>>>>>>> and my rules1.conf has
>>>>>>>
>>>>>>> cond %{HEADER:MY_HEADER} = "foo"
>>>>>>> set-destination HOST mobile.bar.com [L]
>>>>>>>
>>>>>>> This should forward the request to mobile.bar.com if the request has
>>>>>>> 'MY_HEADER' with value 'foo'.
>>>>>>>
>>>>>>>
>>>>>>> Thanks
>>>>>>>
>>>>>>> Adi
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Tue, Jan 24, 2017 at 11:36 AM, Brian Geffon
>>>>>>> <[hidden email]> wrote:
>>>>>>>>
>>>>>>>> Sorry I think I meant header_rewrite.
>>>>>>>>
>>>>>>>> Brian
>>>>>>>>
>>>>>>>>
>>>>>>>> On Tue, Jan 24, 2017, 11:26 Brian Geffon <[hidden email]>
>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>> There is a regex_remap plugin that is what you would want, take a
>>>>>>>>> look in plugins/
>>>>>>>>>
>>>>>>>>> Brian
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Tue, Jan 24, 2017, 11:25 Adi Mallikarjuna Reddy V
>>>>>>>>> <[hidden email]> wrote:
>>>>>>>>>>
>>>>>>>>>> Is there a config that allows to change remap rule based on the
>>>>>>>>>> incoming header?
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> My use case is , if I send a custom header in the request, the
>>>>>>>>>> remap rule should be changed to different one than the default one
>>>>>>>>>> configured.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Thanks
>>>>>>>>>>
>>>>>>>>>> Adi
>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>




Reply | Threaded
Open this post in threaded view
|

RE: remap rules based on request header

Chou, Peter
In reply to this post by Adi Mallikarjuna Reddy V

Can you confirm under $PREFIX/libexec whether your so is libtslua.so or just tslua.so?

 

From: Adi Mallikarjuna Reddy V [mailto:[hidden email]]
Sent: Monday, May 08, 2017 9:19 AM
To: [hidden email]
Subject: Re: remap rules based on request header

 

remap rule

 

map /random_path http://dummy_destination.com/ @pristine_host_hdr=1 @plugin=libtslua.so @pparam=lua_remap.lua

 

script - lua_remap.lua

 

function do_remap()

    ts.client_request.set_url_host('actual_destination.com')

    ts.client_request.set_url_port(80)

    ts.client_request.set_url_scheme('http')

    return TS_LUA_REMAP_DID_REMAP

end

No extra info with debug tag ts_lua enabled, as this seems to be failing to parse the remap config itself.

 

Thanks

Adi

 

On Mon, May 8, 2017 at 9:13 AM, Jeremy Payne <[hidden email]> wrote:

verify your remap rules and/or lua scripts to ensure they are syntactically correct.

 

also enable debug.. .may provide further insight..

 

can you also share your remap file and corresponding lua scripts ?

 

 

 

 

On Mon, May 8, 2017 at 11:00 AM, Adi Mallikarjuna Reddy V <[hidden email]> wrote:

After adding lua plugin with remap rule in remap.config and writing some sample code mentioned in https://docs.trafficserver.apache.org/en/latest/admin-guide/plugins/ts_lua.en.html#ts-client-request-set-url-host I see the following error in traffic server.

 

[May  8 08:57:44.851] Server {0x2aeb0862c2c0} WARNING: Failed to create new instance for plugin libtslua.so (not a TS_SUCCESS return)

[May  8 08:57:44.851] Server {0x2aeb0862c2c0} WARNING: Could not add rule at line #25; Aborting!

[May  8 08:57:44.851] Server {0x2aeb0862c2c0} WARNING: [ReverseProxy] Can't create new remap instance for plugin "libtslua.so" - [TSRemapNewInstance] ts_lua_add_module failed at line 25

[May  8 08:57:44.852] Server {0x2aeb0862c2c0} WARNING: something failed during BuildTable() -- check your remap plugins!

[May  8 08:57:44.852] Server {0x2aeb0862c2c0} WARNING: Can not load the remap table, exiting out!

 

Is there any thing that I am missing out?

 

Thanks

Adi

 

 

On Sun, Feb 5, 2017 at 11:39 PM, Shu Kit Chan <[hidden email]> wrote:

No, you don't need lua runtime on your host. Just compile the
experimental plugin and that's it. More information here -
https://docs.trafficserver.apache.org/en/latest/admin-guide/plugins/ts_lua.en.html

Thanks.

On Wed, Jan 25, 2017 at 5:10 PM, Adi Mallikarjuna Reddy V

<[hidden email]> wrote:
> For this to work, do I have to install Lua runtime on my host?
>
> On Wed, Jan 25, 2017 at 10:49 AM, Jeremy Payne <[hidden email]> wrote:
>>
>> i use the lua plugin to change origin host based on certain conditions.
>>
>>
>> https://docs.trafficserver.apache.org/en/latest/admin-guide/plugins/ts_lua.en.html#ts-client-request-set-url-host
>>
>> On Wed, Jan 25, 2017 at 12:33 PM, Adi Mallikarjuna Reddy V
>> <[hidden email]> wrote:
>>>
>>> any help with this is greatly appreciated. Is there a debug flag to check
>>> header rewrite functionality?
>>>
>>> On Tue, Jan 24, 2017 at 1:42 PM, Adi Mallikarjuna Reddy V
>>> <[hidden email]> wrote:
>>>>
>>>> Thanks Sudheer for the pointer. I tried the following and it looks like
>>>> this condition is not working
>>>>
>>>> cond %{READ_REQUEST_HDR_HOOK}
>>>>
>>>> cond %{CLIENT-HEADER:DEVHOST} = dev103
>>>>
>>>> set-destination HOST dev103.abc.com [L]
>>>>
>>>>
>>>>
>>>> and
>>>>
>>>> curl -H 'DEVHOST:dev103' 'http://actual_ats_endpoint/path' -v doesnt
>>>> take to that host specified.
>>>>
>>>>
>>>>
>>>> Thanks
>>>>
>>>> Adi
>>>>
>>>>
>>>>
>>>> On Tue, Jan 24, 2017 at 12:28 PM, Sudheer Vinukonda
>>>> <[hidden email]> wrote:
>>>>>
>>>>> You'd need to specify a preremap request hook (such as Read Request
>>>>> Header) in your rules. I think the default hook is Send Response Header.
>>>>>
>>>>> - Sudheer
>>>>>
>>>>> On Jan 24, 2017, at 12:24 PM, Adi Mallikarjuna Reddy V
>>>>> <[hidden email]> wrote:
>>>>>
>>>>> Ok, I tried the following one with no luck. The requests are always
>>>>> going to the new host without the customer header value also.
>>>>>
>>>>> cond %{HEADER:DEV_HOST} = "dev102"
>>>>> set-destination HOST dev102.abc.com [L]
>>>>>
>>>>>
>>>>> my remap rule is
>>>>>
>>>>> map / http://abc.com/ @pristine_host_hdr=1 @plugin=header_rewrite.so
>>>>> @pparam=my_header_rules.conf
>>>>>
>>>>>
>>>>> Am I missing anything important here?
>>>>>
>>>>>
>>>>> Thanks
>>>>>
>>>>> Adi
>>>>>
>>>>>
>>>>> On Tue, Jan 24, 2017 at 11:46 AM, Jeremy Payne <[hidden email]>
>>>>> wrote:
>>>>>>
>>>>>> the lua plugin also has this functionality although may be somewhat
>>>>>> overkill for your needs.
>>>>>>
>>>>>>
>>>>>> On Tue, Jan 24, 2017 at 1:43 PM, Adi Mallikarjuna Reddy V
>>>>>> <[hidden email]> wrote:
>>>>>>>
>>>>>>> So to achieve my use case, can I try something like this?
>>>>>>>
>>>>>>> map / http://b.bar.com @plugin=header_rewrite.so @pparam=rules1.conf
>>>>>>>
>>>>>>> and my rules1.conf has
>>>>>>>
>>>>>>> cond %{HEADER:MY_HEADER} = "foo"
>>>>>>> set-destination HOST mobile.bar.com [L]
>>>>>>>
>>>>>>> This should forward the request to mobile.bar.com if the request has
>>>>>>> 'MY_HEADER' with value 'foo'.
>>>>>>>
>>>>>>>
>>>>>>> Thanks
>>>>>>>
>>>>>>> Adi
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Tue, Jan 24, 2017 at 11:36 AM, Brian Geffon
>>>>>>> <[hidden email]> wrote:
>>>>>>>>
>>>>>>>> Sorry I think I meant header_rewrite.
>>>>>>>>
>>>>>>>> Brian
>>>>>>>>
>>>>>>>>
>>>>>>>> On Tue, Jan 24, 2017, 11:26 Brian Geffon <[hidden email]>
>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>> There is a regex_remap plugin that is what you would want, take a
>>>>>>>>> look in plugins/
>>>>>>>>>
>>>>>>>>> Brian
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Tue, Jan 24, 2017, 11:25 Adi Mallikarjuna Reddy V
>>>>>>>>> <[hidden email]> wrote:
>>>>>>>>>>
>>>>>>>>>> Is there a config that allows to change remap rule based on the
>>>>>>>>>> incoming header?
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> My use case is , if I send a custom header in the request, the
>>>>>>>>>> remap rule should be changed to different one than the default one
>>>>>>>>>> configured.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Thanks
>>>>>>>>>>
>>>>>>>>>> Adi
>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>

 

 

 

Reply | Threaded
Open this post in threaded view
|

Re: remap rules based on request header

Adi Mallikarjuna Reddy V
its libtslua.so, we built it as this.

didnt work after removing @pristine_host_hdr=1 and enabling the same through lua script.


I see the same error after above change. Looks like something to do with initialization of plugin.

Thanks
Adi

On Mon, May 8, 2017 at 9:25 AM, Chou, Peter <[hidden email]> wrote:

Can you confirm under $PREFIX/libexec whether your so is libtslua.so or just tslua.so?

 

From: Adi Mallikarjuna Reddy V [mailto:[hidden email]]
Sent: Monday, May 08, 2017 9:19 AM
To: [hidden email]
Subject: Re: remap rules based on request header

 

remap rule

 

map /random_path http://dummy_destination.com/ @pristine_host_hdr=1 @plugin=libtslua.so @pparam=lua_remap.lua

 

script - lua_remap.lua

 

function do_remap()

    ts.client_request.set_url_host('actual_destination.com')

    ts.client_request.set_url_port(80)

    ts.client_request.set_url_scheme('http')

    return TS_LUA_REMAP_DID_REMAP

end

No extra info with debug tag ts_lua enabled, as this seems to be failing to parse the remap config itself.

 

Thanks

Adi

 

On Mon, May 8, 2017 at 9:13 AM, Jeremy Payne <[hidden email]> wrote:

verify your remap rules and/or lua scripts to ensure they are syntactically correct.

 

also enable debug.. .may provide further insight..

 

can you also share your remap file and corresponding lua scripts ?

 

 

 

 

On Mon, May 8, 2017 at 11:00 AM, Adi Mallikarjuna Reddy V <[hidden email]> wrote:

After adding lua plugin with remap rule in remap.config and writing some sample code mentioned in https://docs.trafficserver.apache.org/en/latest/admin-guide/plugins/ts_lua.en.html#ts-client-request-set-url-host I see the following error in traffic server.

 

[May  8 08:57:44.851] Server {0x2aeb0862c2c0} WARNING: Failed to create new instance for plugin libtslua.so (not a TS_SUCCESS return)

[May  8 08:57:44.851] Server {0x2aeb0862c2c0} WARNING: Could not add rule at line #25; Aborting!

[May  8 08:57:44.851] Server {0x2aeb0862c2c0} WARNING: [ReverseProxy] Can't create new remap instance for plugin "libtslua.so" - [TSRemapNewInstance] ts_lua_add_module failed at line 25

[May  8 08:57:44.852] Server {0x2aeb0862c2c0} WARNING: something failed during BuildTable() -- check your remap plugins!

[May  8 08:57:44.852] Server {0x2aeb0862c2c0} WARNING: Can not load the remap table, exiting out!

 

Is there any thing that I am missing out?

 

Thanks

Adi

 

 

On Sun, Feb 5, 2017 at 11:39 PM, Shu Kit Chan <[hidden email]> wrote:

No, you don't need lua runtime on your host. Just compile the
experimental plugin and that's it. More information here -
https://docs.trafficserver.apache.org/en/latest/admin-guide/plugins/ts_lua.en.html

Thanks.

On Wed, Jan 25, 2017 at 5:10 PM, Adi Mallikarjuna Reddy V

<[hidden email]> wrote:
> For this to work, do I have to install Lua runtime on my host?
>
> On Wed, Jan 25, 2017 at 10:49 AM, Jeremy Payne <[hidden email]> wrote:
>>
>> i use the lua plugin to change origin host based on certain conditions.
>>
>>
>> https://docs.trafficserver.apache.org/en/latest/admin-guide/plugins/ts_lua.en.html#ts-client-request-set-url-host
>>
>> On Wed, Jan 25, 2017 at 12:33 PM, Adi Mallikarjuna Reddy V
>> <[hidden email]> wrote:
>>>
>>> any help with this is greatly appreciated. Is there a debug flag to check
>>> header rewrite functionality?
>>>
>>> On Tue, Jan 24, 2017 at 1:42 PM, Adi Mallikarjuna Reddy V
>>> <[hidden email]> wrote:
>>>>
>>>> Thanks Sudheer for the pointer. I tried the following and it looks like
>>>> this condition is not working
>>>>
>>>> cond %{READ_REQUEST_HDR_HOOK}
>>>>
>>>> cond %{CLIENT-HEADER:DEVHOST} = dev103
>>>>
>>>> set-destination HOST dev103.abc.com [L]
>>>>
>>>>
>>>>
>>>> and
>>>>
>>>> curl -H 'DEVHOST:dev103' 'http://actual_ats_endpoint/path' -v doesnt
>>>> take to that host specified.
>>>>
>>>>
>>>>
>>>> Thanks
>>>>
>>>> Adi
>>>>
>>>>
>>>>
>>>> On Tue, Jan 24, 2017 at 12:28 PM, Sudheer Vinukonda
>>>> <[hidden email]> wrote:
>>>>>
>>>>> You'd need to specify a preremap request hook (such as Read Request
>>>>> Header) in your rules. I think the default hook is Send Response Header.
>>>>>
>>>>> - Sudheer
>>>>>
>>>>> On Jan 24, 2017, at 12:24 PM, Adi Mallikarjuna Reddy V
>>>>> <[hidden email]> wrote:
>>>>>
>>>>> Ok, I tried the following one with no luck. The requests are always
>>>>> going to the new host without the customer header value also.
>>>>>
>>>>> cond %{HEADER:DEV_HOST} = "dev102"
>>>>> set-destination HOST dev102.abc.com [L]
>>>>>
>>>>>
>>>>> my remap rule is
>>>>>
>>>>> map / http://abc.com/ @pristine_host_hdr=1 @plugin=header_rewrite.so
>>>>> @pparam=my_header_rules.conf
>>>>>
>>>>>
>>>>> Am I missing anything important here?
>>>>>
>>>>>
>>>>> Thanks
>>>>>
>>>>> Adi
>>>>>
>>>>>
>>>>> On Tue, Jan 24, 2017 at 11:46 AM, Jeremy Payne <[hidden email]>
>>>>> wrote:
>>>>>>
>>>>>> the lua plugin also has this functionality although may be somewhat
>>>>>> overkill for your needs.
>>>>>>
>>>>>>
>>>>>> On Tue, Jan 24, 2017 at 1:43 PM, Adi Mallikarjuna Reddy V
>>>>>> <[hidden email]> wrote:
>>>>>>>
>>>>>>> So to achieve my use case, can I try something like this?
>>>>>>>
>>>>>>> map / http://b.bar.com @plugin=header_rewrite.so @pparam=rules1.conf
>>>>>>>
>>>>>>> and my rules1.conf has
>>>>>>>
>>>>>>> cond %{HEADER:MY_HEADER} = "foo"
>>>>>>> set-destination HOST mobile.bar.com [L]
>>>>>>>
>>>>>>> This should forward the request to mobile.bar.com if the request has
>>>>>>> 'MY_HEADER' with value 'foo'.
>>>>>>>
>>>>>>>
>>>>>>> Thanks
>>>>>>>
>>>>>>> Adi
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Tue, Jan 24, 2017 at 11:36 AM, Brian Geffon
>>>>>>> <[hidden email]> wrote:
>>>>>>>>
>>>>>>>> Sorry I think I meant header_rewrite.
>>>>>>>>
>>>>>>>> Brian
>>>>>>>>
>>>>>>>>
>>>>>>>> On Tue, Jan 24, 2017, 11:26 Brian Geffon <[hidden email]>
>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>> There is a regex_remap plugin that is what you would want, take a
>>>>>>>>> look in plugins/
>>>>>>>>>
>>>>>>>>> Brian
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Tue, Jan 24, 2017, 11:25 Adi Mallikarjuna Reddy V
>>>>>>>>> <[hidden email]> wrote:
>>>>>>>>>>
>>>>>>>>>> Is there a config that allows to change remap rule based on the
>>>>>>>>>> incoming header?
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> My use case is , if I send a custom header in the request, the
>>>>>>>>>> remap rule should be changed to different one than the default one
>>>>>>>>>> configured.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Thanks
>>>>>>>>>>
>>>>>>>>>> Adi
>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>

 

 

 


Reply | Threaded
Open this post in threaded view
|

Re: remap rules based on request header

Shu Kit Chan
A few questions

1) Which ats version you are using?
2) How do you compile/get libtslua.so ?
3) anything in error.log ?

Thanks.


On Mon, May 8, 2017 at 9:37 AM, Adi Mallikarjuna Reddy V
<[hidden email]> wrote:

> its libtslua.so, we built it as this.
>
> didnt work after removing @pristine_host_hdr=1 and enabling the same through
> lua script.
>
>
> I see the same error after above change. Looks like something to do with
> initialization of plugin.
>
> Thanks
> Adi
>
> On Mon, May 8, 2017 at 9:25 AM, Chou, Peter <[hidden email]> wrote:
>>
>> Can you confirm under $PREFIX/libexec whether your so is libtslua.so or
>> just tslua.so?
>>
>>
>>
>> From: Adi Mallikarjuna Reddy V [mailto:[hidden email]]
>> Sent: Monday, May 08, 2017 9:19 AM
>> To: [hidden email]
>> Subject: Re: remap rules based on request header
>>
>>
>>
>> remap rule
>>
>>
>>
>> map /random_path http://dummy_destination.com/ @pristine_host_hdr=1
>> @plugin=libtslua.so @pparam=lua_remap.lua
>>
>>
>>
>> script - lua_remap.lua
>>
>>
>>
>> function do_remap()
>>
>>     ts.client_request.set_url_host('actual_destination.com')
>>
>>     ts.client_request.set_url_port(80)
>>
>>     ts.client_request.set_url_scheme('http')
>>
>>     return TS_LUA_REMAP_DID_REMAP
>>
>> end
>>
>> No extra info with debug tag ts_lua enabled, as this seems to be failing
>> to parse the remap config itself.
>>
>>
>>
>> Thanks
>>
>> Adi
>>
>>
>>
>> On Mon, May 8, 2017 at 9:13 AM, Jeremy Payne <[hidden email]> wrote:
>>
>> verify your remap rules and/or lua scripts to ensure they are
>> syntactically correct.
>>
>>
>>
>> also enable debug.. .may provide further insight..
>>
>>
>>
>> can you also share your remap file and corresponding lua scripts ?
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> On Mon, May 8, 2017 at 11:00 AM, Adi Mallikarjuna Reddy V
>> <[hidden email]> wrote:
>>
>> After adding lua plugin with remap rule in remap.config and writing some
>> sample code mentioned in
>> https://docs.trafficserver.apache.org/en/latest/admin-guide/plugins/ts_lua.en.html#ts-client-request-set-url-host
>> I see the following error in traffic server.
>>
>>
>>
>> [May  8 08:57:44.851] Server {0x2aeb0862c2c0} WARNING: Failed to create
>> new instance for plugin libtslua.so (not a TS_SUCCESS return)
>>
>> [May  8 08:57:44.851] Server {0x2aeb0862c2c0} WARNING: Could not add rule
>> at line #25; Aborting!
>>
>> [May  8 08:57:44.851] Server {0x2aeb0862c2c0} WARNING: [ReverseProxy]
>> Can't create new remap instance for plugin "libtslua.so" -
>> [TSRemapNewInstance] ts_lua_add_module failed at line 25
>>
>> [May  8 08:57:44.852] Server {0x2aeb0862c2c0} WARNING: something failed
>> during BuildTable() -- check your remap plugins!
>>
>> [May  8 08:57:44.852] Server {0x2aeb0862c2c0} WARNING: Can not load the
>> remap table, exiting out!
>>
>>
>>
>> Is there any thing that I am missing out?
>>
>>
>>
>> Thanks
>>
>> Adi
>>
>>
>>
>>
>>
>> On Sun, Feb 5, 2017 at 11:39 PM, Shu Kit Chan <[hidden email]>
>> wrote:
>>
>> No, you don't need lua runtime on your host. Just compile the
>> experimental plugin and that's it. More information here -
>>
>> https://docs.trafficserver.apache.org/en/latest/admin-guide/plugins/ts_lua.en.html
>>
>> Thanks.
>>
>> On Wed, Jan 25, 2017 at 5:10 PM, Adi Mallikarjuna Reddy V
>>
>> <[hidden email]> wrote:
>> > For this to work, do I have to install Lua runtime on my host?
>> >
>> > On Wed, Jan 25, 2017 at 10:49 AM, Jeremy Payne <[hidden email]>
>> > wrote:
>> >>
>> >> i use the lua plugin to change origin host based on certain conditions.
>> >>
>> >>
>> >>
>> >> https://docs.trafficserver.apache.org/en/latest/admin-guide/plugins/ts_lua.en.html#ts-client-request-set-url-host
>> >>
>> >> On Wed, Jan 25, 2017 at 12:33 PM, Adi Mallikarjuna Reddy V
>> >> <[hidden email]> wrote:
>> >>>
>> >>> any help with this is greatly appreciated. Is there a debug flag to
>> >>> check
>> >>> header rewrite functionality?
>> >>>
>> >>> On Tue, Jan 24, 2017 at 1:42 PM, Adi Mallikarjuna Reddy V
>> >>> <[hidden email]> wrote:
>> >>>>
>> >>>> Thanks Sudheer for the pointer. I tried the following and it looks
>> >>>> like
>> >>>> this condition is not working
>> >>>>
>> >>>> cond %{READ_REQUEST_HDR_HOOK}
>> >>>>
>> >>>> cond %{CLIENT-HEADER:DEVHOST} = dev103
>> >>>>
>> >>>> set-destination HOST dev103.abc.com [L]
>> >>>>
>> >>>>
>> >>>>
>> >>>> and
>> >>>>
>> >>>> curl -H 'DEVHOST:dev103' 'http://actual_ats_endpoint/path' -v doesnt
>> >>>> take to that host specified.
>> >>>>
>> >>>>
>> >>>>
>> >>>> Thanks
>> >>>>
>> >>>> Adi
>> >>>>
>> >>>>
>> >>>>
>> >>>> On Tue, Jan 24, 2017 at 12:28 PM, Sudheer Vinukonda
>> >>>> <[hidden email]> wrote:
>> >>>>>
>> >>>>> You'd need to specify a preremap request hook (such as Read Request
>> >>>>> Header) in your rules. I think the default hook is Send Response
>> >>>>> Header.
>> >>>>>
>> >>>>> - Sudheer
>> >>>>>
>> >>>>> On Jan 24, 2017, at 12:24 PM, Adi Mallikarjuna Reddy V
>> >>>>> <[hidden email]> wrote:
>> >>>>>
>> >>>>> Ok, I tried the following one with no luck. The requests are always
>> >>>>> going to the new host without the customer header value also.
>> >>>>>
>> >>>>> cond %{HEADER:DEV_HOST} = "dev102"
>> >>>>> set-destination HOST dev102.abc.com [L]
>> >>>>>
>> >>>>>
>> >>>>> my remap rule is
>> >>>>>
>> >>>>> map / http://abc.com/ @pristine_host_hdr=1 @plugin=header_rewrite.so
>> >>>>> @pparam=my_header_rules.conf
>> >>>>>
>> >>>>>
>> >>>>> Am I missing anything important here?
>> >>>>>
>> >>>>>
>> >>>>> Thanks
>> >>>>>
>> >>>>> Adi
>> >>>>>
>> >>>>>
>> >>>>> On Tue, Jan 24, 2017 at 11:46 AM, Jeremy Payne <[hidden email]>
>> >>>>> wrote:
>> >>>>>>
>> >>>>>> the lua plugin also has this functionality although may be somewhat
>> >>>>>> overkill for your needs.
>> >>>>>>
>> >>>>>>
>> >>>>>> On Tue, Jan 24, 2017 at 1:43 PM, Adi Mallikarjuna Reddy V
>> >>>>>> <[hidden email]> wrote:
>> >>>>>>>
>> >>>>>>> So to achieve my use case, can I try something like this?
>> >>>>>>>
>> >>>>>>> map / http://b.bar.com @plugin=header_rewrite.so
>> >>>>>>> @pparam=rules1.conf
>> >>>>>>>
>> >>>>>>> and my rules1.conf has
>> >>>>>>>
>> >>>>>>> cond %{HEADER:MY_HEADER} = "foo"
>> >>>>>>> set-destination HOST mobile.bar.com [L]
>> >>>>>>>
>> >>>>>>> This should forward the request to mobile.bar.com if the request
>> >>>>>>> has
>> >>>>>>> 'MY_HEADER' with value 'foo'.
>> >>>>>>>
>> >>>>>>>
>> >>>>>>> Thanks
>> >>>>>>>
>> >>>>>>> Adi
>> >>>>>>>
>> >>>>>>>
>> >>>>>>>
>> >>>>>>> On Tue, Jan 24, 2017 at 11:36 AM, Brian Geffon
>> >>>>>>> <[hidden email]> wrote:
>> >>>>>>>>
>> >>>>>>>> Sorry I think I meant header_rewrite.
>> >>>>>>>>
>> >>>>>>>> Brian
>> >>>>>>>>
>> >>>>>>>>
>> >>>>>>>> On Tue, Jan 24, 2017, 11:26 Brian Geffon <[hidden email]>
>> >>>>>>>> wrote:
>> >>>>>>>>>
>> >>>>>>>>> There is a regex_remap plugin that is what you would want, take
>> >>>>>>>>> a
>> >>>>>>>>> look in plugins/
>> >>>>>>>>>
>> >>>>>>>>> Brian
>> >>>>>>>>>
>> >>>>>>>>>
>> >>>>>>>>> On Tue, Jan 24, 2017, 11:25 Adi Mallikarjuna Reddy V
>> >>>>>>>>> <[hidden email]> wrote:
>> >>>>>>>>>>
>> >>>>>>>>>> Is there a config that allows to change remap rule based on the
>> >>>>>>>>>> incoming header?
>> >>>>>>>>>>
>> >>>>>>>>>>
>> >>>>>>>>>> My use case is , if I send a custom header in the request, the
>> >>>>>>>>>> remap rule should be changed to different one than the default
>> >>>>>>>>>> one
>> >>>>>>>>>> configured.
>> >>>>>>>>>>
>> >>>>>>>>>>
>> >>>>>>>>>> Thanks
>> >>>>>>>>>>
>> >>>>>>>>>> Adi
>> >>>>>>>
>> >>>>>>>
>> >>>>>>
>> >>>>>
>> >>>>
>> >>>
>> >>
>> >
>>
>>
>>
>>
>>
>>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: remap rules based on request header

Adi Mallikarjuna Reddy V
1) Which ats version you are using? - 5.3.x
2) How do you compile/get libtslua.so ? - internal build from experimental plugins
3) anything in error.log ? - nothing other than the one posted

On Mon, May 8, 2017 at 12:22 PM, Shu Kit Chan <[hidden email]> wrote:
A few questions

1) Which ats version you are using?
2) How do you compile/get libtslua.so ?
3) anything in error.log ?

Thanks.


On Mon, May 8, 2017 at 9:37 AM, Adi Mallikarjuna Reddy V
<[hidden email]> wrote:
> its libtslua.so, we built it as this.
>
> didnt work after removing @pristine_host_hdr=1 and enabling the same through
> lua script.
>
>
> I see the same error after above change. Looks like something to do with
> initialization of plugin.
>
> Thanks
> Adi
>
> On Mon, May 8, 2017 at 9:25 AM, Chou, Peter <[hidden email]> wrote:
>>
>> Can you confirm under $PREFIX/libexec whether your so is libtslua.so or
>> just tslua.so?
>>
>>
>>
>> From: Adi Mallikarjuna Reddy V [mailto:[hidden email]]
>> Sent: Monday, May 08, 2017 9:19 AM
>> To: [hidden email]
>> Subject: Re: remap rules based on request header
>>
>>
>>
>> remap rule
>>
>>
>>
>> map /random_path http://dummy_destination.com/ @pristine_host_hdr=1
>> @plugin=libtslua.so @pparam=lua_remap.lua
>>
>>
>>
>> script - lua_remap.lua
>>
>>
>>
>> function do_remap()
>>
>>     ts.client_request.set_url_host('actual_destination.com')
>>
>>     ts.client_request.set_url_port(80)
>>
>>     ts.client_request.set_url_scheme('http')
>>
>>     return TS_LUA_REMAP_DID_REMAP
>>
>> end
>>
>> No extra info with debug tag ts_lua enabled, as this seems to be failing
>> to parse the remap config itself.
>>
>>
>>
>> Thanks
>>
>> Adi
>>
>>
>>
>> On Mon, May 8, 2017 at 9:13 AM, Jeremy Payne <[hidden email]> wrote:
>>
>> verify your remap rules and/or lua scripts to ensure they are
>> syntactically correct.
>>
>>
>>
>> also enable debug.. .may provide further insight..
>>
>>
>>
>> can you also share your remap file and corresponding lua scripts ?
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> On Mon, May 8, 2017 at 11:00 AM, Adi Mallikarjuna Reddy V
>> <[hidden email]> wrote:
>>
>> After adding lua plugin with remap rule in remap.config and writing some
>> sample code mentioned in
>> https://docs.trafficserver.apache.org/en/latest/admin-guide/plugins/ts_lua.en.html#ts-client-request-set-url-host
>> I see the following error in traffic server.
>>
>>
>>
>> [May  8 08:57:44.851] Server {0x2aeb0862c2c0} WARNING: Failed to create
>> new instance for plugin libtslua.so (not a TS_SUCCESS return)
>>
>> [May  8 08:57:44.851] Server {0x2aeb0862c2c0} WARNING: Could not add rule
>> at line #25; Aborting!
>>
>> [May  8 08:57:44.851] Server {0x2aeb0862c2c0} WARNING: [ReverseProxy]
>> Can't create new remap instance for plugin "libtslua.so" -
>> [TSRemapNewInstance] ts_lua_add_module failed at line 25
>>
>> [May  8 08:57:44.852] Server {0x2aeb0862c2c0} WARNING: something failed
>> during BuildTable() -- check your remap plugins!
>>
>> [May  8 08:57:44.852] Server {0x2aeb0862c2c0} WARNING: Can not load the
>> remap table, exiting out!
>>
>>
>>
>> Is there any thing that I am missing out?
>>
>>
>>
>> Thanks
>>
>> Adi
>>
>>
>>
>>
>>
>> On Sun, Feb 5, 2017 at 11:39 PM, Shu Kit Chan <[hidden email]>
>> wrote:
>>
>> No, you don't need lua runtime on your host. Just compile the
>> experimental plugin and that's it. More information here -
>>
>> https://docs.trafficserver.apache.org/en/latest/admin-guide/plugins/ts_lua.en.html
>>
>> Thanks.
>>
>> On Wed, Jan 25, 2017 at 5:10 PM, Adi Mallikarjuna Reddy V
>>
>> <[hidden email]> wrote:
>> > For this to work, do I have to install Lua runtime on my host?
>> >
>> > On Wed, Jan 25, 2017 at 10:49 AM, Jeremy Payne <[hidden email]>
>> > wrote:
>> >>
>> >> i use the lua plugin to change origin host based on certain conditions.
>> >>
>> >>
>> >>
>> >> https://docs.trafficserver.apache.org/en/latest/admin-guide/plugins/ts_lua.en.html#ts-client-request-set-url-host
>> >>
>> >> On Wed, Jan 25, 2017 at 12:33 PM, Adi Mallikarjuna Reddy V
>> >> <[hidden email]> wrote:
>> >>>
>> >>> any help with this is greatly appreciated. Is there a debug flag to
>> >>> check
>> >>> header rewrite functionality?
>> >>>
>> >>> On Tue, Jan 24, 2017 at 1:42 PM, Adi Mallikarjuna Reddy V
>> >>> <[hidden email]> wrote:
>> >>>>
>> >>>> Thanks Sudheer for the pointer. I tried the following and it looks
>> >>>> like
>> >>>> this condition is not working
>> >>>>
>> >>>> cond %{READ_REQUEST_HDR_HOOK}
>> >>>>
>> >>>> cond %{CLIENT-HEADER:DEVHOST} = dev103
>> >>>>
>> >>>> set-destination HOST dev103.abc.com [L]
>> >>>>
>> >>>>
>> >>>>
>> >>>> and
>> >>>>
>> >>>> curl -H 'DEVHOST:dev103' 'http://actual_ats_endpoint/path' -v doesnt
>> >>>> take to that host specified.
>> >>>>
>> >>>>
>> >>>>
>> >>>> Thanks
>> >>>>
>> >>>> Adi
>> >>>>
>> >>>>
>> >>>>
>> >>>> On Tue, Jan 24, 2017 at 12:28 PM, Sudheer Vinukonda
>> >>>> <[hidden email]> wrote:
>> >>>>>
>> >>>>> You'd need to specify a preremap request hook (such as Read Request
>> >>>>> Header) in your rules. I think the default hook is Send Response
>> >>>>> Header.
>> >>>>>
>> >>>>> - Sudheer
>> >>>>>
>> >>>>> On Jan 24, 2017, at 12:24 PM, Adi Mallikarjuna Reddy V
>> >>>>> <[hidden email]> wrote:
>> >>>>>
>> >>>>> Ok, I tried the following one with no luck. The requests are always
>> >>>>> going to the new host without the customer header value also.
>> >>>>>
>> >>>>> cond %{HEADER:DEV_HOST} = "dev102"
>> >>>>> set-destination HOST dev102.abc.com [L]
>> >>>>>
>> >>>>>
>> >>>>> my remap rule is
>> >>>>>
>> >>>>> map / http://abc.com/ @pristine_host_hdr=1 @plugin=header_rewrite.so
>> >>>>> @pparam=my_header_rules.conf
>> >>>>>
>> >>>>>
>> >>>>> Am I missing anything important here?
>> >>>>>
>> >>>>>
>> >>>>> Thanks
>> >>>>>
>> >>>>> Adi
>> >>>>>
>> >>>>>
>> >>>>> On Tue, Jan 24, 2017 at 11:46 AM, Jeremy Payne <[hidden email]>
>> >>>>> wrote:
>> >>>>>>
>> >>>>>> the lua plugin also has this functionality although may be somewhat
>> >>>>>> overkill for your needs.
>> >>>>>>
>> >>>>>>
>> >>>>>> On Tue, Jan 24, 2017 at 1:43 PM, Adi Mallikarjuna Reddy V
>> >>>>>> <[hidden email]> wrote:
>> >>>>>>>
>> >>>>>>> So to achieve my use case, can I try something like this?
>> >>>>>>>
>> >>>>>>> map / http://b.bar.com @plugin=header_rewrite.so
>> >>>>>>> @pparam=rules1.conf
>> >>>>>>>
>> >>>>>>> and my rules1.conf has
>> >>>>>>>
>> >>>>>>> cond %{HEADER:MY_HEADER} = "foo"
>> >>>>>>> set-destination HOST mobile.bar.com [L]
>> >>>>>>>
>> >>>>>>> This should forward the request to mobile.bar.com if the request
>> >>>>>>> has
>> >>>>>>> 'MY_HEADER' with value 'foo'.
>> >>>>>>>
>> >>>>>>>
>> >>>>>>> Thanks
>> >>>>>>>
>> >>>>>>> Adi
>> >>>>>>>
>> >>>>>>>
>> >>>>>>>
>> >>>>>>> On Tue, Jan 24, 2017 at 11:36 AM, Brian Geffon
>> >>>>>>> <[hidden email]> wrote:
>> >>>>>>>>
>> >>>>>>>> Sorry I think I meant header_rewrite.
>> >>>>>>>>
>> >>>>>>>> Brian
>> >>>>>>>>
>> >>>>>>>>
>> >>>>>>>> On Tue, Jan 24, 2017, 11:26 Brian Geffon <[hidden email]>
>> >>>>>>>> wrote:
>> >>>>>>>>>
>> >>>>>>>>> There is a regex_remap plugin that is what you would want, take
>> >>>>>>>>> a
>> >>>>>>>>> look in plugins/
>> >>>>>>>>>
>> >>>>>>>>> Brian
>> >>>>>>>>>
>> >>>>>>>>>
>> >>>>>>>>> On Tue, Jan 24, 2017, 11:25 Adi Mallikarjuna Reddy V
>> >>>>>>>>> <[hidden email]> wrote:
>> >>>>>>>>>>
>> >>>>>>>>>> Is there a config that allows to change remap rule based on the
>> >>>>>>>>>> incoming header?
>> >>>>>>>>>>
>> >>>>>>>>>>
>> >>>>>>>>>> My use case is , if I send a custom header in the request, the
>> >>>>>>>>>> remap rule should be changed to different one than the default
>> >>>>>>>>>> one
>> >>>>>>>>>> configured.
>> >>>>>>>>>>
>> >>>>>>>>>>
>> >>>>>>>>>> Thanks
>> >>>>>>>>>>
>> >>>>>>>>>> Adi
>> >>>>>>>
>> >>>>>>>
>> >>>>>>
>> >>>>>
>> >>>>
>> >>>
>> >>
>> >
>>
>>
>>
>>
>>
>>
>
>

12