LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   redirect http request to an ftp server (https://www.linuxquestions.org/questions/linux-server-73/redirect-http-request-to-an-ftp-server-949013/)

x201s 06-07-2012 07:04 AM

redirect http request to an ftp server
 
I used to have my files in the same server where apache is running.
I could access the files like:
http://myserver/download/myfiles

But now I have a situation where the files are hosted in a different server, and it is an ftp server.
I can assess those files from the ftp server:
ftp://myFTPServer/download/myfiles

I need to access those files in the ftp server just like before (using "http://myserver/download/myfiles")

I tried the following:
Code:

<VirtualHost *:80>

  RewriteRule ^/download/myfiles/(.*)$ ftp://myFTPServer/download/myfiles/$1 [P,R] 

</VirtualHost>

No luck.

What could be wrong? Please help!

Thank you.

acid_kewpie 06-07-2012 07:44 AM

what's wrong is that it makes no sense. You using the HTTP protocol, you can't magically just make that hit an FTP server any more than you can an SMTP server... You need an alternative way to reach those files.

wpeckham 06-07-2012 11:45 AM

What he said....
 
If I may add: what you need is an HTTPD server. While APACHE would work it is serious overkill for this. I would use xitami classic (not the version 5), lighttpd (lighty), or another of the small, fast, easy to config servers. Xitami has the advantage of serving both FTP and HTTP at the same time using one engine.

Actually were I doing this, I would use a small fast web-only server and use sftp for the non-web access. You want OpenSSH on there for remote management anyway, and can set up secure and jailed sftp easily using any recent version.

Natch: nothing stops you from installing a WHOLE LOT of servers and making a messy cobble that will do everything you want, but I believe it better to keep things simple, secure, and fast.

x201s 06-08-2012 04:36 AM

wpeckham:
Thanks for the reply. I need to use apache. Company rules.

acid_kewpie:
There are millions of links (of course not literally!) hardcoded with http server reference, and as I wrote our data guys say they can only allow ftp from now on. So the need is real. Of course, I can change all the http referring links to ftp links, but then it will make some people unhappy.

acid_kewpie 06-08-2012 05:02 AM

I'm afraid it doesn't matter how much you want and demand something to be possible, if it's not, it's not. No matter have much I shout and scream about how badly I want it, I can not levitate nor see through walls.

What actual access do you have to this system and each OS? Maybe you can mount the remote server locally and then serve that as if they were local files etc.? You'll need to think "outside the box" as HTTP is NOT FTP, otherwise they wouldn't be called different things.

bathory 06-08-2012 05:35 AM

@OP
Quote:

I tried the following:
Code:

<VirtualHost *:80>

RewriteRule ^/download/myfiles/(.*)$ ftp://myFTPServer/download/myfiles/$1 [P,R]

</VirtualHost>

No luck.

What could be wrong? Please help!
Add a:
Code:

RewriteEngine On
before your rule, in order to enable mod_rewrite

acid_kewpie 06-08-2012 06:20 AM

OK, so I'll leave my comments above untouched to not save face and let anyone have a laugh at my expense :) ... But you're looking at sending back a redirect aren't you? Not a rewrite on the incoming request. Well I look really chuffing stupid now. So mod_rewrite can send back a 302 to an FTP service now, and if that is all you're after then that's doable, however you seem to be suggesting originally that you want the file to come back to the client over HTTP, which is still not going to happen.

x201s 06-09-2012 02:24 PM

Chris:
I am sorry that I may not have been able to describe my requirement precisely due to my insufficient understanding of the terminologies involved but I achieved what I wanted to do by adding that one liner. Thank you, bathory.

One note: I don't know why it worked, but I also had to revise the RE from "(.*)$" to "(..*)$".

Feels so good to see the pieces falling in places.

Thank you all and Cheers,
x201


All times are GMT -5. The time now is 08:08 AM.