I am new with dokku and nginx.
I want to serve images from my server, right now I have an application running in dokku serving me different json from a database. Right now I want to upload files and images and serve that images to the users.
I could find some documentation about dokku persistent storage, to mount a local storage and redirect all the data from the application to that directory.
My question right now is. How can I serve the image to the users? If I user http://app-name.host.com/storage/image-url.jpg it will do the trick?.
Or should I use some configuration from the nginx file to serve the files directly from the server local storage?
Maybe someone could guide me in the right path because I can not find any clear information about that.
Thank you!
You can either:
ship a customized nginx.conf.sigil with your repository to make the external nginx route to the storage directory directly
modify your application to serve it. Most frameworks have this functionality.
Related
I've created a VueJS App for file uploading in which it will be my admin panel (For CMS) with NodeJS as back-end. Now I want to upload the files that was passed to the NodeJS and move it to another VueJS App which is going to be my primary website in order for me to access the files locally. How can I do it? Any suggestions or different approach will do.
You have many options on how to move the files to another site.
You could store them in a shared bucket or shared directory between your 2 backends or you could add another route to download that file.
You could configure a cronjob to scp or rsync those files to your target machine.
This is really more of a question of how to sync a directory to some place else.
I installed Material Design Icons with npm install mdi --save and I am trying from my view access this mdi folder. I am trying to use ../node_modules/mdi/css/materialdesignicons.min.css but this is not working. I know that If I move the files do public I will get them, but this just make no sense. I think there is a way to get those modules even from the View file. What am I missing? Thankss
You will need to move the required files to public. Here's why:
You are serving your Laravel app to the world with a web server (maybe Apache, maybe Nginx, maybe something else). Web servers by design serve only certain files - you do not want a web server providing any old file from your server to clients all over the internet. So, the web server is locked down to prevent access to all of the files on the server except those you want to give access to. That's why we put files in a certain folder (/var/www for Apache).
Somewhere on your server you might have that CSS file in a node_modules directory somewhere. The web server is going to ignore that directory because it is probably not in the directory from which it serves file. To make sure that file is available to your clients, you will need to move it.
I use a elastic-beanstalk service on AWS by using Node.js.
I use a multer for file upload and uploaded file is saved on webserver.
But when I publish a new version of project file, the files that saved on my webserver are gone.
I want to maintain the file on webserver.
just overwrite not rewrite.
so how can I solve this issue?
Thanks for your time!
When working with Elastic Beanstalk (or any auto-scaling environment), ideally you don't want to store anything on the server itself. If a user is uploading a file, save it somewhere off the server.
In AWS, this typically means storing it in S3 - this means that the file doesn't get lost when the project is updated or the server gets terminated.
I have a Node.js application on IBM Bluemix.
I need to let the user upload a image. In my localhost, the image is save into the folder, no problems...
But when I do the same in production, the file isn't save to the server corresponding folder...
Someone can help?
Assuming this is a Cloud Foundry app ... the file system is ephemeral, you need to save the images somewhere external to the app for them to be persisted through app restarts.
There is a sample app that shows how to do this using Cloudant - https://github.com/IBM-Bluemix/nodejs-cloudant
You will need to specify the directory using __dirname , but every time you redeploy your application you will lose the files. Stoping and Restarting should be ok.
I am using AWS to run my application based on MEAN stack. I am using load balancer with three instances of Node application servers and three instances of mongo database server on cluster. My application has feature to upload file contents to server, mainly images, audios, vidoes etc. I want following
I want to create one central content repository which should be accessible from all of my three node application servers so that my node code should be able to upload files to central content repository.
I want to one URL to access this central content repository which can be used on user interface to load assets and display it
I also want to re-purpose this same central repository to host all of my client side javascript, css, images and would like my index.html to refer client side assets from central repository URL
I was looking into options in AWS however go confused. Not able to understand what is best and easy approach. Following is server architecture for reference.
Please advice
I couldn't figure out to use EC2 to solve this problem, so I changed my implementation approach, rather than hosting files on file system, I am using the MongoDB GridFS to store files. It helped to make it available for each nodejs hosts.