You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@trafficserver.apache.org by Guofeng Zhang <gu...@gmail.com> on 2019/04/23 13:01:05 UTC

TS on the private network without internet connection?

Hi,

I need to provide a way for our machines on a private network to download
software somewhere. This private network has no internet connection. I
think this is can be easily accomplished by using TS as a forward proxy
server on the private network.

I can fill the TS's cache by running a script on another machine that has
internet connection to download and cache software by a TS, then copy the
TS's cache directory (which is configured by storage.config) to the TS on
the private network.

I need the TS on the private network to return objects if they are hit, or
return 404 (Not Found) if they are missed, and the TS should not try to
connect to original servers in any case.

By reading the docs, I cannot know how to configure TS on the private
network. I think I can configure it like:
 url_regex=^https?://(www.)?apache.org/dev/ ttl-in-cache=6h
and give ttl-in-cache a very large value. Is it the only configuration to
do it?

Your help is appreciated.

Thanks for your help.

Guofeng

Re: TS on the private network without internet connection?

Posted by Alan Carroll <so...@verizonmedia.com>.
You shouldn't need that configuration on the private network - the cache
TTL is set when the object is cached, not when it is accessed. I would
think you'd want that on the caching TS that is doing the preloaded.

For the 404, you might need to write a plugin (in C or Lua) that sits on
the TS_HTTP_OS_DNS_HOOK and simply sets a 404 status for the response. DNS
lookup isn't done if there is a cache hit.

On Tue, Apr 23, 2019 at 9:01 PM Guofeng Zhang <gu...@gmail.com> wrote:

> Hi,
>
> I need to provide a way for our machines on a private network to download
> software somewhere. This private network has no internet connection. I
> think this is can be easily accomplished by using TS as a forward proxy
> server on the private network.
>
> I can fill the TS's cache by running a script on another machine that has
> internet connection to download and cache software by a TS, then copy the
> TS's cache directory (which is configured by storage.config) to the TS on
> the private network.
>
> I need the TS on the private network to return objects if they are hit, or
> return 404 (Not Found) if they are missed, and the TS should not try to
> connect to original servers in any case.
>
> By reading the docs, I cannot know how to configure TS on the private
> network. I think I can configure it like:
>  url_regex=^https?://(www.)?apache.org/dev/ ttl-in-cache=6h
> and give ttl-in-cache a very large value. Is it the only configuration to
> do it?
>
> Your help is appreciated.
>
> Thanks for your help.
>
> Guofeng
>
>

Re: TS on the private network without internet connection?

Posted by Guofeng Zhang <gu...@gmail.com>.
Thanks all of you for the kind response.
I will test your suggestion late because these days I am busy for other
tasks.
Thanks again.

On Wed, May 8, 2019 at 12:12 AM Bryan Call <bc...@apache.org> wrote:

> You can add the header "Cache-Control: only-if-cached" to the client
> request using header_rewrite.  The client would receive a 504 by default
> and you should be able to modify this to a 404 using the header_rewrite
> plugin again.
>
> *Here is an example of a non cacheable response:*
> 09:07:36 homer:~$ curl -D -   http://127.0.0.1:8080/200.php
> HTTP/1.1 200 OK
> Date: Tue, 07 May 2019 16:07:46 GMT
> Server: ATS/9.0.0
> X-Powered-By: PHP/7.2.17
> Content-Length: 5
> Content-Type: text/html; charset=UTF-8
> Age: 0
> Connection: keep-alive
>
> test
>
> 09:07:46 homer:~$ curl -D - -H 'Cache-Control: only-if-cached'
> http://127.0.0.1:8080/200.php
> HTTP/1.1 504 Not Cached
> Date: Tue, 07 May 2019 16:09:55 GMT
> Connection: keep-alive
> Server: ATS/9.0.0
> Cache-Control: no-store
> Content-Type: text/html
> Content-Language: en
> Content-Length: 340
>
> <HTML>
> <HEAD>
> <TITLE>Not In Cache</TITLE>
> </HEAD>
>
> <BODY BGCOLOR="white" FGCOLOR="black">
> <H1>Not In Cache</H1>
> <HR>
>
> <FONT FACE="Helvetica,Arial"><B>
> Description: Your request mandated that the document come from cache, but
> the document is not present in cache.  As requested, the transaction
> is being terminated.
> </B></FONT>
> <HR>
> </BODY>
>
> *Here is an example of a cacheable response:*
> 09:10:17 homer:~$ curl -D - http://127.0.0.1:8080/200_cache.php
> HTTP/1.1 200 OK
> Date: Tue, 07 May 2019 16:06:48 GMT
> Server: ATS/9.0.0
> X-Powered-By: PHP/7.2.17
> Cache-Control: max-age=300
> Last-Modified: Thu, 12 Feb 2009 23:00:00 GMT
> Content-Length: 4
> Content-Type: text/html; charset=UTF-8
> Age: 219
> Connection: keep-alive
>
> xxx
> 09:10:27 homer:~$ curl -D - -H 'Cache-Control: only-if-cached'
> http://127.0.0.1:8080/200_cache.php
> HTTP/1.1 200 OK
> Date: Tue, 07 May 2019 16:06:48 GMT
> Server: ATS/9.0.0
> X-Powered-By: PHP/7.2.17
> Cache-Control: max-age=300
> Last-Modified: Thu, 12 Feb 2009 23:00:00 GMT
> Content-Length: 4
> Content-Type: text/html; charset=UTF-8
> Age: 221
> Connection: keep-alive
>
> xxx
>
> -Bryan
>
>
>
> On Apr 23, 2019, at 6:01 AM, Guofeng Zhang <gu...@gmail.com> wrote:
>
> Hi,
>
> I need to provide a way for our machines on a private network to download
> software somewhere. This private network has no internet connection. I
> think this is can be easily accomplished by using TS as a forward proxy
> server on the private network.
>
> I can fill the TS's cache by running a script on another machine that has
> internet connection to download and cache software by a TS, then copy the
> TS's cache directory (which is configured by storage.config) to the TS on
> the private network.
>
> I need the TS on the private network to return objects if they are hit, or
> return 404 (Not Found) if they are missed, and the TS should not try to
> connect to original servers in any case.
>
> By reading the docs, I cannot know how to configure TS on the private
> network. I think I can configure it like:
>  url_regex=^https?://(www.)?apache.org/dev/ ttl-in-cache=6h
> and give ttl-in-cache a very large value. Is it the only configuration to
> do it?
>
> Your help is appreciated.
>
> Thanks for your help.
>
> Guofeng
>
>
>

Re: TS on the private network without internet connection?

Posted by Bryan Call <bc...@apache.org>.
You can add the header "Cache-Control: only-if-cached" to the client request using header_rewrite.  The client would receive a 504 by default and you should be able to modify this to a 404 using the header_rewrite plugin again.

Here is an example of a non cacheable response:
09:07:36 homer:~$ curl -D -   http://127.0.0.1:8080/200.php
HTTP/1.1 200 OK
Date: Tue, 07 May 2019 16:07:46 GMT
Server: ATS/9.0.0
X-Powered-By: PHP/7.2.17
Content-Length: 5
Content-Type: text/html; charset=UTF-8
Age: 0
Connection: keep-alive

test

09:07:46 homer:~$ curl -D - -H 'Cache-Control: only-if-cached'  http://127.0.0.1:8080/200.php
HTTP/1.1 504 Not Cached
Date: Tue, 07 May 2019 16:09:55 GMT
Connection: keep-alive
Server: ATS/9.0.0
Cache-Control: no-store
Content-Type: text/html
Content-Language: en
Content-Length: 340

<HTML>
<HEAD>
<TITLE>Not In Cache</TITLE>
</HEAD>

<BODY BGCOLOR="white" FGCOLOR="black">
<H1>Not In Cache</H1>
<HR>

<FONT FACE="Helvetica,Arial"><B>
Description: Your request mandated that the document come from cache, but
the document is not present in cache.  As requested, the transaction
is being terminated.
</B></FONT>
<HR>
</BODY>

Here is an example of a cacheable response:
09:10:17 homer:~$ curl -D - http://127.0.0.1:8080/200_cache.php
HTTP/1.1 200 OK
Date: Tue, 07 May 2019 16:06:48 GMT
Server: ATS/9.0.0
X-Powered-By: PHP/7.2.17
Cache-Control: max-age=300
Last-Modified: Thu, 12 Feb 2009 23:00:00 GMT
Content-Length: 4
Content-Type: text/html; charset=UTF-8
Age: 219
Connection: keep-alive

xxx
09:10:27 homer:~$ curl -D - -H 'Cache-Control: only-if-cached'  http://127.0.0.1:8080/200_cache.php
HTTP/1.1 200 OK
Date: Tue, 07 May 2019 16:06:48 GMT
Server: ATS/9.0.0
X-Powered-By: PHP/7.2.17
Cache-Control: max-age=300
Last-Modified: Thu, 12 Feb 2009 23:00:00 GMT
Content-Length: 4
Content-Type: text/html; charset=UTF-8
Age: 221
Connection: keep-alive

xxx

-Bryan



> On Apr 23, 2019, at 6:01 AM, Guofeng Zhang <gu...@gmail.com> wrote:
> 
> Hi,
> 
> I need to provide a way for our machines on a private network to download software somewhere. This private network has no internet connection. I think this is can be easily accomplished by using TS as a forward proxy server on the private network. 
> 
> I can fill the TS's cache by running a script on another machine that has internet connection to download and cache software by a TS, then copy the TS's cache directory (which is configured by storage.config) to the TS on the private network.
> 
> I need the TS on the private network to return objects if they are hit, or return 404 (Not Found) if they are missed, and the TS should not try to connect to original servers in any case.
> 
> By reading the docs, I cannot know how to configure TS on the private network. I think I can configure it like:
>  url_regex=^https?://(www.)?apache.org/dev/ <http://apache.org/dev/> ttl-in-cache=6h
> and give ttl-in-cache a very large value. Is it the only configuration to do it?
> 
> Your help is appreciated.
> 
> Thanks for your help.
> 
> Guofeng
> 


Re: TS on the private network without internet connection?

Posted by Miles Libbey <ml...@apache.org>.
For an analysis project, I
- wrote a tiny echo server -- all it needs to do in your case is
return 404 and run it on your ATS machine
- made a match-all rule that uses your echo server as the origin. For
instance, if your echo server is running on port 8001:
map / http://127.0.0.1:8001/

I'd think you'd want Pristine Host header to make the cache key the
same as the inbound request host.

miles

On Tue, Apr 23, 2019 at 9:01 PM Guofeng Zhang <gu...@gmail.com> wrote:
>
> Hi,
>
> I need to provide a way for our machines on a private network to download software somewhere. This private network has no internet connection. I think this is can be easily accomplished by using TS as a forward proxy server on the private network.
>
> I can fill the TS's cache by running a script on another machine that has internet connection to download and cache software by a TS, then copy the TS's cache directory (which is configured by storage.config) to the TS on the private network.
>
> I need the TS on the private network to return objects if they are hit, or return 404 (Not Found) if they are missed, and the TS should not try to connect to original servers in any case.
>
> By reading the docs, I cannot know how to configure TS on the private network. I think I can configure it like:
>  url_regex=^https?://(www.)?apache.org/dev/ ttl-in-cache=6h
> and give ttl-in-cache a very large value. Is it the only configuration to do it?
>
> Your help is appreciated.
>
> Thanks for your help.
>
> Guofeng
>