How to make pictures on server be visible on website associated with the server? - html

Currently, there are gigabytes of images stored on a server that I can access using username#serverip. It is not my server, but I have access to it. Using cd Storage followed by ls -l shows all the files that I would like to be able to be accessible to anyone who visits the actual website. However, all of those files, while they are on the server, are not visible on the website and I was wondering how I could go about doing that. Is there a way to make the files on the server be visible on the website as well?

Are these images? Or just assorted files?
In either case, and without knowing what your actual implementation of the website, generally all webservers have a static resources folder.
In this folder you would put things like your general website images, like favicon, etc.
Put all that stuff in there. Or configure the webserver to use the existing one as such. This is not necessarily best practice though as all of those items would be exposed (potentially) without authentication.

Related

Launching project to cloud/production (Node.js + Vue.js)

A while ago, I started a project with Node.js on the back end and Vue.js on the front end. I never saw any difficulties in executing my project in development.
I know that with Vue.js it is possible to generate a dist folder, but I don't understand how to use it.
Now I'm trying to create a docker image with my project and I was in doubt as to how its structure should work, I should create an image for the Back-end and another for the Front-end, and even if it is possible it is recommended to to do? With the docker image I intend to launch the project on Google Cloud.
I also have doubts on the question of the database, whether it should also be in the same docker image or should I separate it from the Back-end?
This is my project structure
It depends on your expected traffic. If you expect a higher load, horizontal scaling would suggest to put them in separate images because then you can scale out the frontend and the backend separately.
frontend
Whether you use CI/CD or not, when building your frontend image you want to use a web server around the frontend, there are options, pick your best known (Apache httpd or Nginx... etc). Make sure that if you are using vue-router you configure your rewrites to send everything to the index.html, otherwise your routing will not work. To finish up within the dockerfile you copy the dist output to your html root.
database
Regarding the database, putting it in the same container would mean that if the backend or frontend fails for any reason your database goes down as well. Don’t do that.
Having it within the same image but running as a separate container might work, though probably very tedious to achieve this, I don’t really see the point to be honest. Just use a dedicated database image and deploy it separately.

How to password protect website hosted on Amazon Web Services (AWS)

I wanted to create a website that would be like a dropbox of sort, which just has files that me and my organization can access. I wanted to password protect the website, just a simple username and password. I have my own domain. I have been looking all over the web to find how to do this(I am a beginner) and found that using httaccess and htpasswd would be used to secure a website similar to what is shown here: http://www.htaccesstools.com/articles/password-protection/
But I cannot seem to get it to work. I am using the s3 bucket and putting the httaccess and htpasswd file in the same folder as the index.html file. Do you know how I would get my site to have a simple password protection(thats not seen in the source code or by typing in the html)? I am not sure if I am finding the directory correctly or not to implement this password protection correctly. Thank you for taking the time to read this and hopefully this makes sense!
Anyone else had this issue?
Amazon AWS alone won't do it. htaccess and htpasswd are also not the right tools for what you want to do.
Get yourself a cheap hosting account with a company like hostgator or godaddy or namecheap or any other that will host your web page and give you PHP and MySQL.
You cannot accomplish what you want just using javascript/jQuery. Those languages run on the browser, but you want to store your files on a server. Therefore, you need the language that controls the server - that is usually PHP. (The other popular solution is ASP, which is by Microsoft and runs on costly and complex Microsoft servers -- PHP is free and runs on (free) Linux and is therefore what ALL of the cheap web hosting companies provide. MySQL is the (free) database that is analogous to Microsoft SQL)
Next, watch a video tutorial on creating a PHP / MySQL login system, such as the ones over at:
phpAcademy (now called codecourse, apparently)
theNewBoston.com
You need to learn more about:
PHP sessions
Ajax
jQuery
MySQL (possibly)
On a basic website, you can stick your files into directories and control who can access those directories by whether or not they are logged in.
You can determine if a visitor is "logged-in" or not by asking for a username/password and setting a session variable. Session variables are just variables that are stored on the server, rather than on a user's own computer (of course, that wouldn't work since every visitor has his own computer and your files are stored on a central server -- so that is where the security (variables) must reside, right?)
Anyway, in a weekend of video watching and trial-and-error you can probably get something cobbled together that will do what you want.

Load time pondering - Images and Domains

So I'm in the process of adding links to images on my web site, and I've come across something interesting.
All the images I'm linking to are housed on another domain, but this domain happens to be located on the same server as the site I'm working on. Now normally I would download images from the other domain and place them in my website's directory structure, so as to avoid having to connect to another server and thus save on load time when grabbing the images on page load. But in this case, with the two file structures being located on the same server, I wonder if the time to download the images on page load would be virtually the same with absolute linking to the 'sibling' domain versus storing the images on my site itself.
Does anybody know if this is the case?? Thanks :)
I think here's where your thinking goes astray:
Now normally I would download images from the other domain and place
them in my website's directory structure, so as to avoid having to
connect to another server and thus save on load time when grabbing the
images on page load.
This is not true. It doesn't save load time to have all the images on the same server. The browser is the client making the request for the image. The server to which the browser makes the request doesn't matter.

How will a CDN work with my site?

I have tried to look for answers for my question but haven't found anything conclusive.
I have a site which, among other things, stores member pictures & thumbnails. They are in separate directories, and within each directory are a cascade of folder names based on properties of the image. This is to prevent thousands of images being in one directory for performance reasons.
for example, a typical image has a URL like:
www.mysite.com/thumbs/100x75/04/18/s3hf9sj_939swzl.jpg
The file location and name are stored in a mysql database so they can be dynamically displayed.
How would a CDN be implemented for my images? Can I recursively select all the images in a directory to be uploaded to the CDN? How often would it update this file information?
And finally, what might happens when the database retrieves a url like the one above? Will the CDN automatically redirect the user to something like this?
www.cdn.mysite.com/thumbs/100x75/04/18/s3hf9sj_939swzl.jpg
Or will I have to design my database differently?
Thank you.
If you choose to migrate to a CDN and not change your URL scheme you would have to make sure requests to www.mysite.com/thumbs/ are routed to your CDN (at www.cdn.mysite.com/thumbs/).
You also need to change your method of saving images to also save a copy to the CDN, or you could create a synchronization script to run periodically, but then you would need to serve your resources from two locations; from your own if the file is not present on the CDN, which would increase the complexity of your setup.
I would make sure I store my resources directly at my CDN at the same time I backup locally and would migrate to a separate domain form my CDN (to allow more concurrent downloads from the user).

Dealing with mass images, some small - some large, in spring/java application using mysql

I was wondering what the best pattern was to handle the management of images these days when using spring/java and mysql.
I have several options. Some of the
images are just small avatars for
the users. Is it fine to put these
directly into mysql? Or use the file
system?
For the larger images, is file
system pretty much the only option,
and then use mysql to store the
location on the file system?
Where is a good spot to put them on
a linux server? /var/files/images?
Since the files are hidden from the
war deployment directory, what is
the best way to stream them? Use
some kind of a file output stream as
the response body for an http
request?
Also, do I have to develop all of
the file management stuff myself,
like cleaning up unused files and
the like?
What about image security? Some images should not be accessed by everyone. I think I'd need to use a separate url with Spring security checking the current user for this.
I'd appreciate advice on all of these questions. Thanks.
You could use MySQL, and that would have the advantage of centralization and easy cleanup, but IMHO it's a waste of the database's resources if you plan to scale.
For data like images where everything is public, consider something like Amazon S3 which allows you to serve images directly from S3's web servers. If you plan to host everything yourself, just serve from a directory. Just remember to turn directory listings off :)