IT:Web Site: Difference between revisions

From Atmospheric and Oceanic Science
Jump to navigation Jump to search
No edit summary
 
Line 25: Line 25:
Restricting access to a certain directory and only giving access to it to users under our control, is possible through password protection. Following these steps will create a directory <code> ~/public_html/secure </code> which is a restricted directory under our personal webspace:
Restricting access to a certain directory and only giving access to it to users under our control, is possible through password protection. Following these steps will create a directory <code> ~/public_html/secure </code> which is a restricted directory under our personal webspace:
# Create the directory <code> ~/public_html/secure </code> and set permissions: <br> <code>mkdir ~/public_html/secure </code> <br> <code>chmod 755 ~/public_html/secure </code>
# Create the directory <code> ~/public_html/secure </code> and set permissions: <br> <code>mkdir ~/public_html/secure </code> <br> <code>chmod 755 ~/public_html/secure </code>
# Create a file called <code> ~/public_html/secure/.htaccess </code> with the following contents:<br> <nowiki>
# Create a file called <code> ~/public_html/secure/.htaccess </code> with the following contents:  
AuthType Basic
<nowiki>
AuthName "Restricted Access"
  AuthType Basic
AuthUserFile "/aos/home/AOS_USERNAME/.htpasswd" # Note: Use full path!
  AuthName "Restricted Access"
require valid-user
  AuthUserFile "/aos/home/AOS_USERNAME/.htpasswd" # Note: Use full path!
  require valid-user  
  </nowiki>
  </nowiki>
This file instructs the webserver that we want the ~/public_html/secure directory to be password protected with basic authentication against the file ~/.htpasswd and any user in this file can access the page.
This file instructs the webserver that we want the ~/public_html/secure directory to be password protected with basic authentication against the file ~/.htpasswd and any user in this file can access the page.
#
#

Latest revision as of 17:16, 24 August 2021

Creating a website

All AOS users have available to them the ability to publish webpages. In order to do so, please perform the following:

  1. If it does not already exist, create the directory public_html,
    mkdir ~/public_html
  2. Ensure the permissions on the directry are set correctly,
    chmod 755 ~/public_html
  3. Create your first webpage called index.html in the public_html directory. The following is a template you can use,
 <html>
   <head>
      <title>Sample AOS Webpage</title>
   </head>
   <body>
      This is my very own sample AOS webpage.
   </body>
 </html> 
 
  1. Visit https://web.meteo.mcgill.ca/~AOS_USERNAME to view your created page

Notes

  • Placing files in your ~/public_html directory is a good way to share things with others instead of by sending large email attachments.
  • Placing sensitive data in your ~/public_html directory is silly. Don't do it.
  • We have directory indexing turned on by default so you can create a directory under ~/public_html and put files there. When you visit https://web.meteo.mcgill.ca/~AOS_USERNAME/directory you will receive an index of that directory.

Password Protection

Restricting access to a certain directory and only giving access to it to users under our control, is possible through password protection. Following these steps will create a directory ~/public_html/secure which is a restricted directory under our personal webspace:

  1. Create the directory ~/public_html/secure and set permissions:
    mkdir ~/public_html/secure
    chmod 755 ~/public_html/secure
  2. Create a file called ~/public_html/secure/.htaccess with the following contents:
  AuthType Basic
  AuthName "Restricted Access"
  AuthUserFile "/aos/home/AOS_USERNAME/.htpasswd" # Note: Use full path!
  require valid-user 
 

This file instructs the webserver that we want the ~/public_html/secure directory to be password protected with basic authentication against the file ~/.htpasswd and any user in this file can access the page.