Changes between Version 1 and Version 2 of Iam2023/Agenda/SP-Installation-VHosts


Ignore:
Timestamp:
Mar 30, 2023, 9:28:23 AM (20 months ago)
Author:
admin
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Iam2023/Agenda/SP-Installation-VHosts

    v1 v2  
    159159}}}
    160160
     161= Registering your Domain Names and DNS configuration for your Domains =
     162
     163As you know we can't use any preferred domain for our services, websites as we wanted to do. First we have to register them in a relevant domain registry where usually we have to pay. In case you want a ac.lk sub domain you have to get it through LEARN. Once you get your domains registered they are to be assigned IP addresses so that they can be used in your services for hosting services, websites etc. Assigning of IP addresses to the domain names is done through DNS lookup service. This DNS service is also can be accomplished through the relevant domain registry or web hosting service. For the ac.lk domain, LEARN or your institutional network/system administrator will do that for you.
     164
     165Receiving domains costs or need the approval from the System Administrator. Hence, for this workshop we can use hosts file in your computer operating system to create any arbitrary domain for your self. Hosts file will override any public DNS but only for your own computer.
     166
     167== Add domains to the hosts file in Windows ==
     168
     169To add domains to the hosts file in Windows please Run the Notepad as the Adminitrator as below.
     170
     171[[Image(https://ws.learn.ac.lk/raw-attachment/wiki/Csle2022/Agenda/databaseandweb/web29.png)]]
     172
     173Then go to /Windows/System32/drivers/etc directory. If you cannot view hosts file please select All Files from the drop down list at bottom. Now open hosts file.
     174
     175[[Image(https://ws.learn.ac.lk/raw-attachment/wiki/Csle2022/Agenda/databaseandweb/web30.png)]]
     176
     177Now as below edit the hosts file and add you domains with the IP address of your guest VM.
     178
     179[[Image(https://ws.learn.ac.lk/raw-attachment/wiki/Csle2022/Agenda/databaseandweb/web31.png)]]
     180
     181== Add domains to the hosts file in Linux ==
     182
     183To add domains to the hosts file edit the hosts file as below. Once done save it.
     184
     185{{{
     186nano /etc/hosts
     187
     188
     189127.0.0.1 localhost
     190127.0.1.1 web
     19110.1.1.240 web.your_domain.com
     19210.1.1.240 wp.your_domain.com
     19310.1.1.240 lms.your_domain.com
     19410.1.1.240 xy.your_2nd_domain.com
     195}}}
     196
     197Now you should be able to access the virtual hosts by their domain names within the computer.
     198
     199To check it you can ping to the domain or browse from the web browser.
     200
     201{{{
     202ping wp.your_domain.com
     203ping xy.your_2nd_domain.com
     204}}}
     205
     206
    161207== Apache Virtual Host Configuration ==
    162208
     
    213259As below you can use any of the above methods. Follow the steps as you prefer.
    214260
     261openssl req -x509 -newkey rsa:4096 -keyout /etc/ssl/private/ssl-lms.key -out /etc/ssl/certs/ssl-lms.crt -nodes -days 1095
     262
     263
     264You are about to be asked to enter information that will be incorporated
     265into your certificate request.
     266What you are about to enter is what is called a Distinguished Name or a DN.
     267There are quite a few fields but you can leave some blank
     268For some fields there will be a default value,
     269If you enter '.', the field will be left blank.
     270-----
     271Country Name (2 letter code) [AU]:LK
     272State or Province Name (full name) [Some-State]:Central Province
     273Locality Name (eg, city) []:Peradeniya
     274Organization Name (eg, company) [Internet Widgits Pty Ltd]:LEARN
     275Organizational Unit Name (eg, section) []:IT Division
     276Common Name (e.g. server FQDN or YOUR name) []:lms.dhammikalalantha.com
     277Email Address []:lalantha@learn.ac.lk
     278
     279sudo a2enmod ssl
     280
     281sudo systemctl restart apache2
     282
     283nano lms-ssl.conf
     284
     285<IfModule mod_ssl.c>
     286        <VirtualHost *:443>
     287
     288                ServerName lms.dhammikalalantha.com
     289                ServerAdmin you@yourwebsite.com
     290                DocumentRoot /var/www/lms.dhammikalalantha.com/public_html
     291
     292                ErrorLog ${APACHE_LOG_DIR}/lms-error.log
     293                CustomLog ${APACHE_LOG_DIR}/lms-access.log combined
     294       
     295
     296                SSLCertificateFile /etc/ssl/certs/ssl-lms.crt
     297                SSLCertificateKeyFile /etc/ssl/private/ssl-lms.key
     298
     299                RewriteEngine on
     300                RewriteCond %{SERVER_NAME} =lms.dhammikalalantha.com
     301                 RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent] # port 80 -- > 443 redirection
     302        </VirtualHost>
     303</IfModule>
     304
     305a2ensite lms-ssl.conf
    215306
    21630710. Let'sencrypt setup (Skip this step if you already configured SSL with self signed or CA provided certificates)