Changes

Jump to: navigation, search

OPS335 Lab 6

2,863 bytes added, 19:50, 16 March 2019
Controlling Access to Pages
# As the root user on your gateway/host, try to forward incoming http connections that arrive on your host to the web server on vm1. Use an iptables command something like this:<br><source>iptables -t nat -A PREROUTING -i *yourinterface* -p tcp --dport 80 -j DNAT --to 192.168.X.2</source>
# You will also need to create a rule in the FORWARD chain in the default table to accept connections to port 80.
# To test this setup you'll need to use another machine outside your own network. If you are using an SSD and VMWare, you can simply use the windows host. If you are using a removable drive, ask a classmate on another PC to try to use a browser to view your web pageact as the partner. That person will have to In either case, enter your host's external interface IP number address in their browser's address window. # Have that person the partner machine view both '''index.html''' and '''index.php'''
# Create a new directory called '''private''' inside your '''DocumentRoot''' and move index.php inside it.
# Have your partner view both files again.<br><br>You will now modify the settings on the web-server to prevent machines outside our network from accessing the private directory.<br><br>
# Add the following directory statement to your apache configuration file. The default pathname for the apache configuration file is: '''/etc/httpd/conf/httpd.conf''' (NOTE: replace the X with your own network octet): {{Admon/important |Do not overwrite existing settings|There should already be two Directory statements in that file. One for '''/var/www''' and one for '''/var/www/html'''. Add your new Directory statement after them. Do not overwrite them.}} <source>
<Directory "/var/www/html/private">
AllowOverride None
== INVESTIGATION 2: SETTING UP AN ONLINE DATABASE==
We complete the last The next piece of the puzzle by is installing, configuring , and running a database server to support your webmail application that will be installed and setup later in a later this lab.
=== Install, Configure and Run MySQL Database Server ===
# Re-start the web-server and try to access the page from another machine. Make sure that you can '''not''' do so before you continue.
# Install the '''php-mysql''' module so that the installation of php your web server is using can execute sql statements. You will have to restart the service after installing it.
#Modify the index.php page in your private directory to match the code below. This will test that your web server can connect to the database (replace the <user, > and <password, and database > with values appropriate for your machine):<br><source>
<?php
$mysqli = new mysqli("localhost", "<user>", "<password", "database>");
if ($mysqli->connect_errno) {
echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
== INVESTIGATION 3: INSTALL, CONFIGURE &amp; RUN WEBMAIL APPLICATION (Roundcube Mail) ==
 
*This investigation was under construction after it somehow did not get saved properly. Students in Fall 2017 are not required to complete this investigation.
{|cellpadding="15" width="40%" align="right"
<ol><li>Perform a search on the roundcube application in order to access the website.</li>
<li>Either Download the "zipped tarball" from their website from a direct link or use the wget command to download directly from a download link (This part may take some effort depending on the Sourceforge website).</li>
<li>Extract the "zipped tarball" and rename the generated directory that contains download source code to: '''webmail'''. Also make sure that '''webmail''' is a sub-directory of your '''DocumentRoot'''.
* Use the '''--no-same-owner''' option when extracting the tar achive to ensure that the files do not keep the original owner (who will not exist on your system).</li>
<li>Change the ownership of the '''temp''' and '''logs''' directories so they belong to apache.</li>
</li>
::If your machine does not have the semage command, use yum to install the policycoreutils-python package.
<li>You will also need to tell selinux to allow the webserver to open connections to the MTAs with <source>setsebool -P httpd_can_network_connect 1</source></li><li>In the directory now named "webmail", there will be a file named '''INSTALL''' which will walk you through the rest of the Roundcube installation.<br /><br />Some installation tips to consider:
::* Be careful about copying &amp; pasting the MySQL setup part: take time and pay attention to detail: do not try to "rush it".
::* You will need to install additional Apache modules including: '''php-xml''' and '''php-mbstring'''.
::* Don't forget to set the password in the roundcube configuration.</li> <li>To make things easier, RoundCube has a well configured installation page available through your local web browser (You will see a note about it in the '''INSTALL''' file).</li>  ::* Go onto your host, open Firefox and on the address bar type "vm1.<yourSenecaID>.ops/webmail/installer", make sure your dns on host can resolve the web address. Alternatively, instead of "vm1.<yourSenecaID>.ops" you can input the ip address of your vm1, "192.168.X.2/webmail/installer", change X to your own IP octet. ::* Inside the web browser installer, ensure all required options are "'''ok'''", if "'''DOM: not ok'''" it means you need to install additional php packages (yum install php-xml php-mbstring). Once everything is ready (it will not let you continue otherwise) click next go to the next page. ::* On the next page, insert "vm3.<yourSenecaID>.ops" under the '''imap settings''' '''default_host''' field and "143" in '''default_port''' field. Insert "vm2.<yourSenecaID>.ops" under '''smtp settings''' '''smtp_server''' field, and "25" in '''smtp_port''' field. ::* Under '''Database setup''' '''db_dsnw''', enter "localhost" as your database server, "roundcubemail" for database name. Put "roundcube" as Database user, and the password you set for the roundcube user when you configured that in the previous steps for database password. Everything else can be left as default. ::* Click next to create the configuration file, then download it to your host. By default it will be saved under "~SenecaID/Downloads". Transfer the files to vm1 using scp and place it inside /var/www/html/webmail/config folder. ::* Go to test config page if you are not there already and "Check config file" should be ok. "Check DB config" should also be ok, if not check your mysql settings. ::* Finally test your configuration by sending email using your smtp server through test field provided by webmail installer, you should receive a test email sent by RoundCube. Test your IMAP settings by simply loging in with your SenecaID and vm3 password on the same webpage. ::* If everything works properly you can skip to step 10. *Remember you can edit the configuration file manually by editing "/var/www/html/webmail/config/config.inc.php".
</li>
<li>Note that both of your IMAP and SMTP servers are on different machines (i.e. not on vm1). Therefore, you will need to set should see custom values in the following options for parameters in the Roundcubeconfiguration file:
::* '''$config['smtp_server']'''
</li>
<li>You should be able to test the configuration in your Now that you have Roundcube installer after completing Step 3. One installed it is able time to contact both servers, test if the roundcube webmail application is working by logging onsending on, then sending and receiving e-mail messages.:
*Using a webbrowser, navigate to vm1.<yourdomain>.ops/webmail and login.
*Use the interface provided to send and receive email.</li><li>If mail sent through roundcube is sending from the wrong domain (i.e. user@vm3.yourdomain.ops instead of user@yourdomain.ops), each user can override it in the settings tab, or you can set:::* '''$config['mail_domain']''' </li></ol>
'''Record steps, commands, and your observations in INVESTIGATION 3 in your OPS335 lab log-book'''
572
edits

Navigation menu