Skip to main content

Posts

Showing posts with the label web

Secured web server

This post is mainly about configuring secured web server. Certificates generation related will be discussed in future. There's a package required to be installed, mod_ssl. yum install -y mod_ssl After installation, httpd needs to be restarted, and firewall rule should be updated, if it's meant to be accessible by other machines. systemctl restart httpd firewall-cmd --permanent --add-service=https firewall-cmd --reload When you try to access, you'll get this. You can proceed by Add Exception to view the page. If I try to access https://test.com (based on the existing setup continue from yesterday virtual web server , I'll get this. Why? This is because test.com is point to the same IP, and this URL is only set to listen to port 80, not port 443. When a match is not found, it will always refer back to the DocumentRoot in /etc/httpd/conf/httpd.conf. If additional setting as below is setup, it will point to the "actual" test.com content ...

Virtual web server

I am not sure what it is actually called, virtual web server or virtual host, whatever. This configuration is to allow multiple web applications to be hosted in single machine. The default configuration file of httpd service is at /etc/httpd/conf/httpd.conf. Notable default settings are : ServerRoot "/etc/httpd" Listen 80 DocumentRoot "/var/www/html" ServerRoot : where the server configuration/log files are kept. Listen : listening to which port DocumentRoot : where the incoming requests will refer to <ifmodule dir_module> DirectoryIndex index.html </ifmodule> The above section sets the default file that Apache will serve if a directory is requested. Another "default" DocumentRoot location to put your hosted files are at /srv/<folder>/www. We will use this location to host our virtual host. Now, let's proceed to create the configuration file in /etc/httpd/conf.d/ Now, let's create the index.html file. Take note...

Configuring a web server

This post is mainly about configuring the web server. The html or any other programming related is not covered. Basic web server setup Install httpd. yum install -y httpd Enable and start httpd. systemctl enable httpd systemctl start httpd The default content path is at /var/www/html. I created the index.html file, and try to access to it via http. Dynamic web server using cgi The default cgi path is at /var/www/cgi-bin. I'll be using perl for the dynamic content. Install perl. yum install -y perl The default path for cgi files are at /var/www/cgi-bin. You'll need to make the file executable. Dynamic web server with SQL Install MariaDB, enable and start it. MariaDB is fork of MySQL. If you are looking for a truly open-source version, this can be your choice. yum groupinstall -y mariadb systemctl enable mariadb systemctl start mariadb I just use whatever is raw available in the database. The example snippet of code below is NOT SECURE AT ALL...

CGI - Common Gateway Interface

What is the first thing come to your mind, when you see... CGI? Me -- Perl. But it's actually more than Perl. Here's some examples on CGI in different languages and some setups on Ubuntu to get the web server running. To setup Apache2 in Ubuntu. This will install and run the Apache2 server : sudo apt-get install apache2 By default, the cgi directory is setup at /usr/lib/cgi-bin . Just have your cgi scripts or executable put in this directory (make sure it's executable) and it can be access via http://localhost/cgi-bin/ path. This can be modified at the config file. The default config file is at /etc/apache2/sites-available/default . The section of the file that related to this looked like this : ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory> The access and error log can be found at /var/log/a...