Apache not serving from CIFS-mounted share, works if it's mounted as SMBFS

Apache not serving from CIFS-mounted share, works if it's mounted as SMBFS

Post by Rick Onania » Thu, 13 Mar 2008 01:34:41



I'd like to mount a windows 2000 server fileshare on an linux/apache
server to do some basic web serving. The web server works fine and
shows other content that's stored locally just fine.

This works:
 mount -t smbfs -o username=smbusername,uid=apache,ro //server/share
mountpoint/
but it complains that smbfs is deprecated and I should be using cifs.
For now, I'm using it anyway.

This seems to work:
 mount.cifs //server/share mountpoint/ -
ouser=smbusername,uid=apache,ro
but it won't serve actual files. It allows browsing of the directories
and shows the filenames. It does not return an error, it just does not
send the file. I have confirmed that user 'apache' can read the file
by logging in as that user and viewing the file.

I tried a telnet test, using GET and Host commands captured from
firefox's LiveHTTPHeaders extension, like this:
-=-
 telnet webserver 80
 GET /directory/filename.jpg HTTP/1.1
 Host: webserver
-=-

The result looks like this:
-=-
 HTTP/1.x 200 OK
 Date: Tue, 11 Mar 2008 15:51:07 GMT
 Server: Apache/2.2.4 (Unix) PHP/5.2.0
 Last-Modified: Thu, 21 Feb 2008 16:07:30 GMT
 Etag: "420f8a5-180bf4-4d7a7480"
 Accept-Ranges: bytes
 Content-Length: 1575924
 Keep-Alive: timeout=5, max=100
 Connection: Keep-Alive
 Content-Type: image/jpeg

 Connection to host lost.
-=-

 
 
 

Apache not serving from CIFS-mounted share, works if it's mounted as SMBFS

Post by Jack Snodgras » Thu, 13 Mar 2008 02:35:35



> I'd like to mount a windows 2000 server fileshare on an linux/apache
> server to do some basic web serving. The web server works fine and
> shows other content that's stored locally just fine.

> This works:
>  mount -t smbfs -o username=smbusername,uid=apache,ro //server/share
> mountpoint/
> but it complains that smbfs is deprecated and I should be using cifs.
> For now, I'm using it anyway.

> This seems to work:
>  mount.cifs //server/share mountpoint/ -
> ouser=smbusername,uid=apache,ro
> but it won't serve actual files. It allows browsing of the directories
> and shows the filenames. It does not return an error, it just does not
> send the file. I have confirmed that user 'apache' can read the file
> by logging in as that user and viewing the file.

> I tried a telnet test, using GET and Host commands captured from
> firefox's LiveHTTPHeaders extension, like this:
> -=-
>  telnet webserver 80
>  GET /directory/filename.jpg HTTP/1.1
>  Host: webserver
> -=-

> The result looks like this:
> -=-
>  HTTP/1.x 200 OK
>  Date: Tue, 11 Mar 2008 15:51:07 GMT
>  Server: Apache/2.2.4 (Unix) PHP/5.2.0
>  Last-Modified: Thu, 21 Feb 2008 16:07:30 GMT
>  Etag: "420f8a5-180bf4-4d7a7480"
>  Accept-Ranges: bytes
>  Content-Length: 1575924
>  Keep-Alive: timeout=5, max=100
>  Connection: Keep-Alive
>  Content-Type: image/jpeg

>  Connection to host lost.
> -=-

what does the apache error log show ( if anything ).
What does the apache log file show for the filename.jpg file?
   If you get a good return code in the apache log... does the bytes
sent match the file size?

Does it work with smaller files and just not larger files.
Can you do cp filename.jpg /tmp and have it get copied correctly?

what does wget -O erase.me "http://127.0.0.1/directory/filename.jpg"
give you when you run it from your webserver. does the erase.me
file have the correct number of bytes when the transfer completes?

Just wondering if the web server is having access files for 'large'
files or files after 'x' bytes and your just not seeing it getting
a directory index listing.

--
D.A.M. - Mothers Against Dyslexia

see http://www.jacksnodgrass.com for my contact info.

jack - Grapevine/Richardson

 
 
 

Apache not serving from CIFS-mounted share, works if it's mounted as SMBFS

Post by Rick Onania » Thu, 13 Mar 2008 22:24:02




Quote:> what does the apache error log show ( if anything ).
> What does the apache log file show for the filename.jpg file?
> ? ?If you get a good return code in the apache log... does the bytes
> sent match the file size?

Nothing. I was thinking maybe I should turn up the logging level.

Quote:> Does it work with smaller files and just not larger files.

No, I tried with very small files (~300 bytes), small files (50k), and
somewhat larger files (2mb).

Quote:> Can you do cp filename.jpg /tmp and have it get copied correctly?

Yes.

Quote:> what does wget -O erase.me "http://127.0.0.1/directory/filename.jpg"
> give you when you run it from your webserver. does the erase.me
> file have the correct number of bytes when the transfer completes?

Good idea, I hadn't thought of that. The output is interesting,
actually:
-=-

SmartBoard/SmartBoard.jpg'
--09:18:00--  http://127.0.0.1/~collegepictures/2006/SmartBoard/SmartBoard.jpg
           => `SmartBoard.jpg'
Connecting to 127.0.0.1:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 763,685 (746K) [image/jpeg]

 0%
[                                                                                                                  ]
0             --.--K/s

09:18:00 (0.00 B/s) - Connection closed at byte 0. Retrying.

--09:18:01--  http://127.0.0.1/~collegepictures/2006/SmartBoard/SmartBoard.jpg
  (try: 2) => `SmartBoard.jpg'
Connecting to 127.0.0.1:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 763,685 (746K) [image/jpeg]
SmartBoard.jpg has sprung into existence.
Retrying.

--09:18:03--  http://127.0.0.1/~collegepictures/2006/SmartBoard/SmartBoard.jpg
  (try: 3) => `SmartBoard.jpg.1'
Connecting to 127.0.0.1:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 763,685 (746K) [image/jpeg]

 0%
[                                                                                                                  ]
0             --.--K/s

09:18:03 (0.00 B/s) - Connection closed at byte 0. Retrying.

--09:18:06--  http://127.0.0.1/~collegepictures/2006/SmartBoard/SmartBoard.jpg
  (try: 4) => `SmartBoard.jpg.1'
Connecting to 127.0.0.1:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 763,685 (746K) [image/jpeg]
SmartBoard.jpg.1 has sprung into existence.
Retrying.
-=-

I like that "sprung into existence" thing. :) Anyway, at that point I
gave up and hit ctrl-C.

Okay, I googled for that sprung into existence bit and found this,
which makes sense:

I didn't even notice but it was incrementing the filename before
saying it sprung into existence.

Quote:> Just wondering if the web server is having access files for 'large'
> files or files after 'x' bytes and your just not seeing it getting
> a directory index listing.

It's definitely not an issue of file size.
 
 
 

Apache not serving from CIFS-mounted share, works if it's mounted as SMBFS

Post by John Chi » Sat, 29 Mar 2008 05:45:19


I ran into this issue also and found the resolution.  Here's the
information I found - http://nixforums.org/about127225.html

Just set the following in your httpd.conf file -

EnableSendfile off




> > what does the apache error log show ( if anything ).
> > What does the apache log file show for the filename.jpg file?
> >    If you get a good return code in the apache log... does the bytes
> > sent match the file size?

> Nothing. I was thinking maybe I should turn up the logging level.

> > Does it work with smaller files and just not larger files.

> No, I tried with very small files (~300 bytes), small files (50k), and
> somewhat larger files (2mb).

> > Can you do cp filename.jpg /tmp and have it get copied correctly?

> Yes.

> > what does wget -O erase.me "http://127.0.0.1/directory/filename.jpg"
> > give you when you run it from your webserver. does the erase.me
> > file have the correct number of bytes when the transfer completes?

> Good idea, I hadn't thought of that. The output is interesting,
> actually:
> -=-

> SmartBoard/SmartBoard.jpg'
> --09:18:00--  http://127.0.0.1/~collegepictures/2006/SmartBoard/SmartBoard.jpg
>            => `SmartBoard.jpg'
> Connecting to 127.0.0.1:80... connected.
> HTTP request sent, awaiting response... 200 OK
> Length: 763,685 (746K) [image/jpeg]

>  0%
> [                                                                                                                  ]
> 0             --.--K/s

> 09:18:00 (0.00 B/s) - Connection closed at byte 0. Retrying.

> --09:18:01--  http://127.0.0.1/~collegepictures/2006/SmartBoard/SmartBoard.jpg
>   (try: 2) => `SmartBoard.jpg'
> Connecting to 127.0.0.1:80... connected.
> HTTP request sent, awaiting response... 200 OK
> Length: 763,685 (746K) [image/jpeg]
> SmartBoard.jpg has sprung into existence.
> Retrying.

> --09:18:03--  http://127.0.0.1/~collegepictures/2006/SmartBoard/SmartBoard.jpg
>   (try: 3) => `SmartBoard.jpg.1'
> Connecting to 127.0.0.1:80... connected.
> HTTP request sent, awaiting response... 200 OK
> Length: 763,685 (746K) [image/jpeg]

>  0%
> [                                                                                                                  ]
> 0             --.--K/s

> 09:18:03 (0.00 B/s) - Connection closed at byte 0. Retrying.

> --09:18:06--  http://127.0.0.1/~collegepictures/2006/SmartBoard/SmartBoard.jpg
>   (try: 4) => `SmartBoard.jpg.1'
> Connecting to 127.0.0.1:80... connected.
> HTTP request sent, awaiting response... 200 OK
> Length: 763,685 (746K) [image/jpeg]
> SmartBoard.jpg.1 has sprung into existence.
> Retrying.
> -=-

> I like that "sprung into existence" thing. :) Anyway, at that point I
> gave up and hit ctrl-C.

> Okay, I googled for that sprung into existence bit and found this,
> which makes sense:

> I didn't even notice but it was incrementing the filename before
> saying it sprung into existence.

> > Just wondering if the web server is having access files for 'large'
> > files or files after 'x' bytes and your just not seeing it getting
> > a directory index listing.

> It's definitely not an issue of file size.

 
 
 

1. 'mount -t cifs' only works with IP addresses, not with hostnames

Facts:

 1) There is a Samba server on the local network.

 2) Its hostname is 'myserver' and its IP address is 192.168.42.1.

 3) The hostname can be resolved via DNS from another computer,
    as illustrated below:

--- 8< ---

 anothercomputer:~ > ping -c 1 myserver
 PING myserver (192.168.42.1): 56 data bytes
 64 bytes from 192.168.42.1: icmp_seq=0 ttl=128 time=0.4 ms

 --- myserver ping statistics ---
 1 packets transmitted, 1 packets received, 0% packet loss
 round-trip min/avg/max = 0.4/0.4/0.4 ms

--- 8< ---

However, this does not work:

--- 8< ---

 anothercomputer:~ > mount -t cifs -o username=foo,password=xyzzy \
 //myserver/sharename /mnt/foobar

 mount: Mounting //myserver/sharename on /mnt/foobar failed: \
 Invalid argument

--- 8< ---

Then again, this _does_ work:

--- 8< ---

 anothercomputer:~ > mount -t cifs -o username=foo,password=xyzzy \
 //192.168.42.1/sharename /mnt/foobar

 anothercomputer:~ >

--- 8< ---

What gives? Any ideas?

By googling around a bit it seems there are numerous questions about the
same problem on the net - on various mailing lists, forums, and
newsgroups - but no answers.

* * *

Note 1: This is _not_ a WINS problem. I'm not trying to use NETBIOS
names! I have no need for NETBIOS name resolution.

Note 2: This is not a generic DNS problem, either. As you can see from
the 'ping' sample output above, resolving 'myserver' to an IP address
works just fine.

Note 3: Explicitly adding 'myserver' to the local '/etc/hosts' file does
not help, either. I have tried that already.

--
znark

2. Bash path question in Cygwin

3. Possible to mount Samba filesys (smbfs) via ordinary 'mount' command?

4. IPNAT + IPCHAINS on offcial Redhat 6.1

5. NFS mount won't mount at boot, but mount -a works fine.

6. WP8 again

7. Can't mount smbfs as user (vfs.usermount=1 doesn't work).

8. CERN security

9. PISED OFF about cifs (mounts w/guest logons do not work)

10. Samba/smbfs, ncpfs -- works, but can't figure out how to mount

11. Mounting an AS400 IFS share

12. "mount -f smbfs //etc" - where to put so it mounts automagically?

13. mount.smbfs : 'Bad adress'...