Linux - Server This forum is for the discussion of Linux Software used in a server related context. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
06-07-2012, 07:04 AM
|
#1
|
Member
Registered: Dec 2010
Posts: 67
Rep:
|
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.
|
|
|
06-07-2012, 07:44 AM
|
#2
|
Moderator
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417
|
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.
|
|
|
06-07-2012, 11:45 AM
|
#3
|
LQ Guru
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS, Manjaro
Posts: 6,165
|
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.
|
|
|
06-08-2012, 04:36 AM
|
#4
|
Member
Registered: Dec 2010
Posts: 67
Original Poster
Rep:
|
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.
|
|
|
06-08-2012, 05:02 AM
|
#5
|
Moderator
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417
|
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.
|
|
|
06-08-2012, 05:35 AM
|
#6
|
LQ Guru
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,223
|
@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:
before your rule, in order to enable mod_rewrite
|
|
1 members found this post helpful.
|
06-08-2012, 06:20 AM
|
#7
|
Moderator
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417
|
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.
|
|
|
06-09-2012, 02:24 PM
|
#8
|
Member
Registered: Dec 2010
Posts: 67
Original Poster
Rep:
|
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 04:10 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|