LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 06-07-2012, 07:04 AM   #1
x201s
Member
 
Registered: Dec 2010
Posts: 67

Rep: Reputation: 0
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.
 
Old 06-07-2012, 07:44 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
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.
 
Old 06-07-2012, 11:45 AM   #3
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,598

Rep: Reputation: 2691Reputation: 2691Reputation: 2691Reputation: 2691Reputation: 2691Reputation: 2691Reputation: 2691Reputation: 2691Reputation: 2691Reputation: 2691Reputation: 2691
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.
 
Old 06-08-2012, 04:36 AM   #4
x201s
Member
 
Registered: Dec 2010
Posts: 67

Original Poster
Rep: Reputation: 0
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.
 
Old 06-08-2012, 05:02 AM   #5
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
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.

Last edited by acid_kewpie; 06-08-2012 at 05:04 AM.
 
Old 06-08-2012, 05:35 AM   #6
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
@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
 
1 members found this post helpful.
Old 06-08-2012, 06:20 AM   #7
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
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.
 
Old 06-09-2012, 02:24 PM   #8
x201s
Member
 
Registered: Dec 2010
Posts: 67

Original Poster
Rep: Reputation: 0
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to redirect http request in squid ? gardenair Linux - Networking 2 01-11-2011 12:14 AM
Redirect FTP request to another machine - vsftpd neo571 Linux - Server 2 11-08-2009 07:11 AM
redirect https request to http after user authentication r.r.vishwanath@gmail.com Linux - Newbie 1 01-31-2009 11:42 AM
Network Installation Help Request (FTP or HTTP) slacker9876 SUSE / openSUSE 3 03-23-2006 12:10 AM
apache: http redirect for any request going to www.foo.com/* psychobyte Linux - Software 1 04-11-2005 05:57 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 09:48 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration