Windows | Nginx Mapped Hard Drive | Network Sharing

So i tried sharing my hard drives on windows and serving the content on
them from nginx but nginx returns a 404 not found error every time.

Answered your question here:

Best regards,
Kevin

Kevin W.
[email protected]

http://twitter.com/kworthington

Apart from Kevin’s answer, if you are running nginx as a service that
service must map the drive letter and then start nginx.
When you map a drive as a user the service running nginx does not have
access to that user-mapped drive.

Posted at Nginx Forum:

Replied on SO. Mirroring here:

Try removing the root and index blocks from the server block. Leave it
only in the location block.


Kevin W.
[email protected]

http://twitter.com/kworthington

Same issue removed it from the server block i don’t think nginx is
compatible with windows network sharing.

Subject: Re: Windows | Nginx Mapped Hard Drive | Network Sharing
From: [email protected]
Date: Fri, 4 Apr 2014 18:08:44 -0400
To: [email protected]

Replied on SO. Mirroring here:
Try removing the root and index blocks from the server block. Leave it
only in the location block.

–Kevin
[email protected]://kevinworthington.com/http://twitter.com/kworthington
On Apr 4, 2014, at 6:01 PM, C0nw0nk W0nky [email protected] wrote:

Thanks for the response i posted my config and tried you way but still
no luck nginx delivers dynamic content fine but as for the static
content that it should be delivering from the mapped hard drive it just
keeps saying 404 not found.
Date: Fri, 4 Apr 2014 16:47:55 -0400
Subject: Re: Windows | Nginx Mapped Hard Drive | Network Sharing
From: [email protected]
To: [email protected]

Answered your question here:

Best regards,
Kevin

Kevin W.
[email protected]

http://twitter.com/kworthington

On Fri, Apr 4, 2014 at 4:30 PM, C0nw0nk W0nky [email protected]
wrote:

So i tried sharing my hard drives on windows and serving the content on
them from nginx but nginx returns a 404 not found error every time.


nginx mailing list

[email protected]

http://mailman.nginx.org/mailman/listinfo/nginx


nginx mailing list
[email protected]
http://mailman.nginx.org/mailman/listinfo/nginx


nginx mailing list
[email protected]
http://mailman.nginx.org/mailman/listinfo/nginx

c0nw0nk Wrote:

Same issue removed it from the server block i don’t think nginx is
compatible with windows network sharing.

It is compatible and works perfectly when done properly, post conf and
describe how drives are mapped and in which context nginx is running.

Posted at Nginx Forum:

Here is my config.

server {
listen 80;
listen [::]:80;
server_name domain.com www.domain.com;

root   z:/server/websites/ps/public_www;
index index.php index.html index.htm default.html default.htm;
location / {
root   z:/server/websites/ps/public_www;
proxy_set_header X-Real-IP  $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_pass   http://127.0.0.1:8000;
expires 3s;
max_ranges 0;
}
location ~ \.flv$ {
flv;
limit_rate 200k;
root   z:/server/websites/ps/public_www;
expires max;
}
location ~ \.mp4$ {
limit_rate 200k;
root   z:/server/websites/ps/public_www;
expires max;
}
location ~ \.gif$ {
limit_rate 50k;
root   z:/server/websites/ps/public_www;
expires max;
}
location ~* \.(avi|m4v|mov|divx|webm|ogg|mp3|mpeg|mpg|zip|rar)$ {
limit_rate 90k;
root   z:/server/websites/ps/public_www;
expires max;
}
location ~*

.(ico|png|jpg|jpeg|gif|flv|mp4|avi|m4v|mov|divx|webm|ogg|mp3|mpeg|mpg|swf|css|js|txt|zip|rar|xml)$
{
root z:/server/websites/ps/public_www;
expires max;
}
# deny access to .htaccess files, if Apache’s document root
# concurs with nginx’s one
#
location ~ /.ht {
return 404;
}
location ~
^/(xampp|security|phpmyadmin|licenses|webalizer|server-status|server-info|cpanel|configuration.php)
{
return 404;
}
}

For my machine running nginx connecting to my mapped hard drive. The
hard
drive name is Z:/

I Have apache running on port 8000 for php and html files only serving
static content. All dynamic content is served by nginx. But when i go to
access a nginx file i get given a 404 not found error.

Posted at Nginx Forum:

Sorry made a mistake and can’t edit my previous post. Nginx handles all
static content and Apache handles all dynamic content.

Posted at Nginx Forum:

Thanks for the response i posted my config and tried you way but still
no luck nginx delivers dynamic content fine but as for the static
content that it should be delivering from the mapped hard drive it just
keeps saying 404 not found.
Date: Fri, 4 Apr 2014 16:47:55 -0400
Subject: Re: Windows | Nginx Mapped Hard Drive | Network Sharing
From: [email protected]
To: [email protected]

Answered your question here:

Best regards,
Kevin

Kevin W.
[email protected]

http://twitter.com/kworthington

On Fri, Apr 4, 2014 at 4:30 PM, C0nw0nk W0nky [email protected]
wrote:

So i tried sharing my hard drives on windows and serving the content on
them from nginx but nginx returns a 404 not found error every time.


nginx mailing list

[email protected]

http://mailman.nginx.org/mailman/listinfo/nginx

Also if it helps my current version of nginx is 1.5.12

Posted at Nginx Forum:

I tested it earlier with 1.5.12…

Best regards,
Kevin

Kevin W.
[email protected]

http://twitter.com/kworthington

I did a simple config:

server {
listen 80;
server_name localhost;

root Y:/www.mydomain.nl;
index index.php index.html index.htm default.html default.htm;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
#proxy_pass http://127.0.0.1:8000;
expires 3s;
max_ranges 0;
}

deny access to .htaccess files, if Apache’s document root

concurs with nginx’s one

location ~ /.ht {
return 404;
}
location ~
^/(xampp|security|phpmyadmin|licenses|webalizer|server-status|server-info|cpanel|configuration.php)
{
return 404;
}
}

And accessed http://localhost/Disclaimer.txt
which works perfectly, your config is not optimal but the share works as
it
suppose to.
so its definitely a config issue and not a share issue.

Posted at Nginx Forum:

Try:

server {
listen 80;
listen [::]:80;
server_name domain.com www.domain.com;

# removed lines here...

location / {
root   z:/server/websites/ps/public_www;
proxy_set_header X-Real-IP  $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_pass   http://127.0.0.1:8000;
expires 3s;
max_ranges 0;
}
location ~ \.flv$ {
flv;
limit_rate 200k;
root   z:/server/websites/ps/public_www;
expires max;
}
location ~ \.mp4$ {
limit_rate 200k;
root   z:/server/websites/ps/public_www;
expires max;
}
location ~ \.gif$ {
limit_rate 50k;
root   z:/server/websites/ps/public_www;
expires max;
}
location ~* \.(avi|m4v|mov|divx|webm|ogg|mp3|mpeg|mpg|zip|rar)$ {
limit_rate 90k;
root   z:/server/websites/ps/public_www;
expires max;
}
location ~*

.(ico|png|jpg|jpeg|gif|flv|mp4|avi|m4v|mov|divx|webm|ogg|
mp3|mpeg|mpg|swf|css|js|txt|zip|rar|xml)$
{
root z:/server/websites/ps/public_www;
expires max;
}
# deny access to .htaccess files, if Apache’s document root
# concurs with nginx’s one
#
location ~ /.ht {
return 404;
}
location ~
^/(xampp|security|phpmyadmin|licenses|webalizer|server-
status|server-info|cpanel|configuration.php)
{
return 404;
}
}

Best regards,
Kevin

Kevin W.
[email protected]

http://twitter.com/kworthington

I think it is a nginx issue it works fine on the localhost and i have
full
read write and execute access to that hard drive via my remote machine
even
browsing it and confirm the files exsist nginx keeps saying 404 not
found.

I think its a bug.

Posted at Nginx Forum:

Yep that is my current config and i still recieve a 404 error accessing
my
static files jpg, mp4, flv etc.

Posted at Nginx Forum:

c0nw0nk Wrote:

Try it with a mp4,flv,jpg file. Not documents that have a plain text
mime type.

127.0.0.1 - - [05/Apr/2014:12:58:46 +0200] “GET /29092007003.mp4
HTTP/1.1”
200 245770434 “-” “Mozilla/5.0 (Windows NT CISNSA; Win32; x86)
Gecko/20100101 Firefox/28.0”

Also works fine as expected.

Posted at Nginx Forum:

If you look at that picturei think that is why i have a 404 error.
Because
when i first connect to the drive all works fine i can access the media,
Then i restart nginx and it says 404 not found.

What is the file path to delete the caches of the windows file shares.

Posted at Nginx Forum:

c0nw0nk Wrote:

Because when i first connect to the drive all works fine i can access
the media, Then i restart nginx and it says 404 not found.

What is the file path to delete the caches of the windows file shares.

There is no cache as such, shares can get in a disconnect state (the
infamous red cross), see Mapped drive is disconnected - Windows Client | Microsoft Learn

The best way to access shared media is via its UNC, ea.
\192.168.1.10\sharename\media and have guest access enabled.

Posted at Nginx Forum:

Try it with a mp4,flv,jpg file. Not documents that have a plain text
mime type.

Thanks for the information and sorry for making so many posts and such a
fuss over it. I think i may have found the true culprit behind this
silly
error.

In my Http server section of my nginx config i had this.

#open_file_cache max=900000 inactive=10m;
#open_file_cache_valid 20m;
#open_file_cache_min_uses 1;
#open_file_cache_errors on;

I nulled out my open file cache and what do you know i can restart nginx
as
much as i like and no issues. :slight_smile:

So it is open_file_cache that is incompatible with the network sharing
feature on windows.

Posted at Nginx Forum: