What's the best strategy for flutter-web to access its resources on server? - apache

I've deployed a release in an ubuntu server with apache. When I access the deployed app, it shows in console: Error while trying to use the following icon from the Manifest: https://mydomain/icons/Icon-192.png (Download error or resource isn't a valid image).
Seems like flutter web is trying to download the Icon-192.png that resides on a subdirectory without permissions, giving me a Forbidden error.
I'd like to know, what's the best approach to access contents (assets like favicon, images, etc) on the deployed directory and subdirectories without making it public.

Related

Web server has no permission to access files on network drive

I want to use DDEV as a local development environment. The setup was successful and the website (a WordPress) is running.
Currenty our team is using XAMPP and to avoid downloading large files on every local machine we create symbolic links (e.g. the "uploads" folder in WordPress). The target is a network drive. So everyone in our team has access to the same files.
Now I want to do the same with DDEV. In WSL I mounted the network drive and created a symbolic link. Inside the console I have full access to the mounted directory, I can create, edit and remove files.
But when I access a file with the browser I get the following error message:
403 Forbidden. You don't have permission to access this resource.
The same error occurs when I try to upload a new file within WordPress.
Is there any way to give the webserver the permission to view and modify the files on a network drive?
The Webserver is an Apache/2.4.38.
As #rfay mentioned I had to add the network drive as volume so it's accessible by the web container. Therefore I created a new docker-compose-file within the .ddev directory (see also in the docs: https://ddev.readthedocs.io/en/stable/users/extend/custom-compose-files/#docker-compose42yaml-examples).
Additionally the permissions on the network drive were incorrect.

Rails 4 images in public folder are not loading on Apache development

I am new to rails. I am working on a sample application for social networking. I have managed to upload the profile picture of users manually (By copying the image uploaded to /tmp/image to the public folder- public/images/tmp/image) and saved the path to db as avatar_url.
In the profile view I used
<%= image_tag(#userinfo.avatar_url, :alt=>"Avatar image")%>
and getting the picture when running on the rails server.
But after that I have deployed the app in apache with passenger in the development environment by setting RailsEnv development. After that the images are not loading. I tried to go to myip:80/public/images/tmp/image, and it gives Routing Error.
After searching on the web, I found that adding config.serve_static_assets = true in production.rb will solve the problem in production. But no use for me because it also stated that the static files will serve in development by default. For confirming the problem again, I started the rails server and opened localhost:3000/profile, image is there and not getting the image in myip:80/profile.
So do I need to add any other config. Or am I not supposed to do that in this way.
Finally, I got the solution for my problem. Just sharing here.
The problem was actually because of permission issues. The picture will be created in a root temp directory on the form submission. Then I copied the image form the temp folder to the public folder. Hence it has only read permissions. After I deployed it, the image gets returns 403 forbidden error.
I used,
FileUtils.chmod 775, target
to set the permission. After that it worked well.
The option config.serve_static_assets = true tells rails to serve the static assets for your application, but that job should really be left to Apache.
Your issue sounds more related to your Apache configuration than rails.
I would take a look at a tutorial on how to configure Apache and Passenger to make sure your environment is setup correctly.
Anything in the public folder should be served by the web server. However myip:80/public/images/tmp/image is not a valid path. You would need to also have a filename at the end with an extension.

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?

not able to deploy war file in jelastic cloud

I developed a web application using java and mongodb. I used glassfish server.
I tried to deploy it on jelastic cloud service
I uploaded my war file. But when I run it after deploying the war file it shows a 404 error. Why? The project works fine on my machine.
There are at least few potential causes:
your app needs some resources which are not started by default (such as DerbyDB). In this case you can check GlassFish log file - server_instance.log for more details.
you are trying to get resources from wrong context, make sure you are trying to get it via correct context name