ImageResizer triggering login redirect on a virtual directory - imageresizer

I am using Image resizer just fine in other areas of my site to resize local images, but when trying to resize an image that is in a virtual directory, I am getting the login screen. (Logging in does not change anything) If I add the '.ashx' extension, I get the same result.
The site is hosted on IIS 10 (integrated mode), with the appPool identity granted modify permissions on the site directory. The virtual directory is using a network user that has modify permissions on the network folder. The debug output does not show any errors -- I've posted the gist [here]
I can access images in the virtual directory without a resizing querystring (image.jpg instead of image.jpg?width=100) and the images are served up normally. However, as soon as I add a resizing command to the querystring, I get the login screen.
Any suggestions on what I am doing wrong?
Thanks,

Nathanael had the solution above in the comments -- to solve the issue, I created a network user and granted modify privileges on the shared network folder to that user. I then set that same user as the application pool identity. Thanks for the help Nathanael!

Related

Block the user from viewing files in the directory via the url

I'm pretty new in developing for VB.NET. I have a web application and I want to block the access to the files in a directory.
For example:
If the user access the following page: application.com/example/page.aspx
If the user remove the page name and type "application.com/example/", he will see all the files inside the folder "example".
I want to block this possibility and, when a user try to access the files, redirect to an error page.
I know how to solve this in PHP through htaccess, but I have never done it by VB.NET. Any help?
If you are using IIS then
Go to your sites-->Desired Site
From Features Views Select Directory Browsing disabled.
web.config or .htaccess will do.
Remember it is a security risk to have directories open for anyone to see.

Access forbidden in /web directory Symfony2 project

I'm working on a Symfony2 project at local server without any virtual hosting or something else. After I run the command php app/console assets:install --symlink, clear the cache and refresh the page none styles or javascript or images are loaded. Inspecting the source code and trying to access any of those assets I get this error:
You don't have permission to access
/cmplatform/web/bundles/clanmovilcommon/css/bootstrap.min.css on this
server.
What I need to change in my /etc/httpd/conf/httpd.conf to fix that problem? It's related to .htaccess problem or what?
This error is due to the user that you are currently logged in as not having correct to write to the /cmplatform/web directory. Or you have not got the root path set correctly in your apache.conf.
Can you confirm other pages / assets are being served correctly.
Take a look at who owns the directory and either adjust the write permissions or add your user / web server to own the directory or into the group.
This is quite a common issue - and care needs to be taken to ensure that write permissions for web, cache and log directories are set correctly to allow command line and web server (e.g. apache / nginx) users.
See http://symfony.com/doc/current/book/installation.html - permissions for some tips about fixing this.

Rails/Paperclip - Can't see uploaded images

I have a Rails 3 application which has an attachment model and uses Paperclip gem. Everything works fine on development environment but on production server we cannot access any of the images uploaded. The images are in the right folder where they are supposed to be but when I try to reach them on browser I simply get the 404 page.
The upload folder is located under public folder and called "uploads"
I can access this: "app_url/uploads/test.html" which I manually created to see if it works
But I cannot acces this: "app_url/uploads/test.jpg" which I upload within the application via Paperclip.
I can guess this has something to do with the server configuration but I'm not an expert and may need help about it.
Thanks
UPDATE
I've just realised that uploaded files belong to "nobody" and when I manually change the owner to "root" it seems to be working fine. So I need to find a way to tell Paperclip make the files belong to "root"
It's not a good idea to have a web application being able to write files as root. File permissions are derived from the process writing the files. In case you're using Passenger, there's the concept of user switching:
http://www.modrails.com/documentation/Users%20guide%20Apache.html#PassengerDefaultUser
Upon startup of your app, Passenger tries to figure out which user owns those files, and tries to switch it's application process to that user. In case it fails, "nobody" is the default.
Check your application permissions on the file level. You should have one user account per application on your server. The application (the directory and contents above the public directory) should be owned by this user. Files under public should be readable by others, so the webserver can pick them up, too.
Are you using Capistrano for deployment?

ImageResizer not working with virtual directories

I am using the ImageResizer successfully on other areas of my site where the images are being served from a folder within the application (both .jpg?width=100 & .jpg.ashx?width=100 work), but when I try images from a virtual directory located on the local machine, I can only get resizing to work if I specify the image page using the "jpg.ashx?width=100" method.
The site's application pool is using NetworkService identity and the virtual folder has pass-through authentication enabled. I've granted Modify permissions to NetworkService on the virtual folder too hoping that would help.
I am using IIS 7.5 in Classic Mode and the resizer diagnostics page doesn't show any issues.
Does anyone have ideas on why this may be happening? Any help would be appreciated.
Thanks!
Classic Mode requires the .ashx syntax, since ASP.NET doesn't see static file requests.
If you're seeing different behavior within the same site on the same host, then your virtual folder is probably NOT a virtual folder, it's likely a sub-application.

Virtual Directory pointing to UNC share

I have an app that uploads documents to the server through the standard
When sent my application to the production server, I found out that they had the server load balanced. My solution to this was to place the upload directory into a network share and then create a virtual directory pointing to the share.
I have set permissions on the share and the file itself, but I keep getting "access denied" whenever I try to upload a document.
Where could I be missing permissions? Is it possible that IUSR needs to have access to the share?
Thanks.
FYI,
The answer to this solution for me was to setup temporary impersonation with a user account that had access to the share, the folder and the virtual directory.
Here's a link to the code that worked for me:
http://support.microsoft.com/kb/306158#4
I hope your site use anonymous access. Otherwise you will have a painful experience.
If it is so ( anonymous acess), then: The IUSR is a local user on the production servers and not a domain user. So it don't have access the the share. You will have to change that to a domain user ( in the site configuration and not on the application pool). And make sure that the application pool run on a network service ( this is the default ) and it should work.
Chances are that whatever your ASP.Net process is running as does not have access to the share.
So chances are you need to set up an IIS6 application pool to run as a domain user and have that domain user have access rights to the file share.
Don't forget to aspnet_regiis -ga {domainuser} so that the domain user can actually run asp.net applications.