Skip to main content

Posts

Showing posts with the label networking

API Gateway Using KrakenD

The increasing demands of users for high-quality web services create the need to integrate various technologies into our application. This will cause the code base to grow larger, making maintenance more difficult over time. A microservices approach offers a solution, where the application is built by combining multiple smaller services, each with a distinct function. For example, one service handles authentication, another manages business functions, another maintains file uploads, and so on. These services communicate and integrate through a common channel. On the client side, users don't need to understand how the application is built or how it functions internally. They simply send a request to a single endpoint, and processes like authentication, caching, or database querying happen seamlessly. This is where an API gateway is effective. It handles user requests and directs them to the appropriate handler. There are several tools available for building an API gateway, su...

Configuring Network Interface on Red Hat Server

For this instance, we use a Red Hat Enterprise Linux (RHEL) Server 7.9. Unlike the latest Ubuntu version that commonly utilizes YAML-based configuration and the netplan tool for setting up IP addresses of network interfaces, the RHEL network interface can be configured using the configuration script located in /etc/sysconfig/network-scripts . Several interface configurations and scripts have been automatically generated by RHEL during the installation process. The configuration file is named by its device name such as ifcfg-eth0 for the eth0 device. If we run our RHEL in a VMware-based virtual machine, the device name might be shown up like ens35 or such things. The following configuration is an example of a network configuration with DHCP enabled. #/etc/sysconfig/network-scripts/ifcfg-eth0 TYPE="Ethernet" PROXY_METHOD="none" BROWSER_ONLY="no" BOOTPROTO="dhcp" DEFROUTE="yes" IPV4_FAILURE_FATAL="no" IPV6INIT="yes...

Limiting Bitrate and Network Throttling

We may limit incoming or outcoming data rates to/from our infrastructure to maintain the stability of our service for customers. Bitrate limitation is an action to limit the number of bits that can be passed through a transmission channel in a period of time. Network throttling is an intentional action to slow down transmission speed in a network channel. It is not only about limiting bitrate but also limiting the allowed number of requests in a period of time. There are several tools and techniques that can be used to apply bitrate limitation and network throttling. Wondershaper It is an easy-to-use tool for Linux and is already in the package repository. It can limit the bit rate that can be achieved by network interfaces in the system. We can install it by running the following command. apt install wondershaper We can choose an interface to have a limitation either or both on download and upload. wondershaper <interface-name> <download-rate-in-bps> <upload-...

Retrive Real Client IP in Nginx

Sometimes, your web application is installed in a web server which is behind reverse proxy server like Cloudflare or other services. In that condition, your application will always read the reverse proxy server IP as client IP. In Nginx, you can use ngx_http_realip_module to get the real client IP ( see detail ). To enable this module, you need to make sure that you use latest Nginx server from repository or you can build it from source with --with-http_realip_module  configuration parameter. I  prefer to install it from repository as Nginx 1.10.0 in Ubuntu 16.04 has enabled this module by default. You can check whether it's enabled or not by following command. $ nginx -V Then, the reslut should be like: $ nginx version: nginx/1.10.0 (Ubuntu) ... ... --with-http_realip_module ... ... Now, you can put the module configuration in http block or server block of your Nginx configuration. For example, you use Cloudflare service for your web application. You should lis...

Master Slave Replication to Automatically Backup Your MySQL Database

We can make backup for some databases by periodically running a kind of dump query, like mysqldump in MySQL. That's the simplest method but it can drain our server resources and it's not suitable for large databases. MySQL comes up with master-slave features that allow you to replicate your database to another location (slave). This mechanism enables MySQL to generate a log file which records any action performed to the database. Then, that action will be run in slave database too. For example, we have two database servers with IP address 192.168.0.1 (Master) and 192.168.0.2 (Slave). 1) Configure my.cnf in master server # Master Settings # locate where the changes record will be stored log-bin = /var/log/mysql/mysql-bin.log # set unique ID for master database in master-slave network (up to you) server-id = 111 innodb_flush_log_at_trx_commit = 1 sync_binlog = 1 # select database which will be replicated # by default system will log all databases binlog-do-db = ...

Setting Up SSL Certificate

Nowadays, an SSL certificate which is usually used for HTTPS connections become pretty important. Even Google starts to give a ranking boost to secure HTTPS/SSL sites . There are several cheap certificates that you can buy like Comodo PositiveSSL. I usually buy cheap certificates from Namecheap.com  which provides SSL certificates as low as $4/year. After you buy the certificate, you need to set up your server. Here are the steps to set up an SSL certificate on your server. 1. Purchase the certificate You can buy the certificate from Namecheap.com . After you buy it, you need to activate your certificate by providing your generated CSR file. 2. Generate private key and CSR file In a Linux server, you can run the following command on the terminal to generate a private key and CSR file. $ openssl req -new -newkey rsa:2048 -nodes -keyout mydomain.com.key -out mydoain.com.csr   When you run the command, you will be asked for Country ID, domain name, registrant...

Eclipse SVN through Proxy

If you are working with Eclipse and using SVN connector to checkout SVN projects through proxy, you may got error messages like " RA layer request failed svn: OPTIONS... " It happens because SVN connector doesn't use Eclipse proxy setting. If you have configured proxy setting on Eclipse Preferences, it doesn't make SVN connector to work. Eclipse subversion plugin use some configuration files which are located in " C:/Users/<username>/AppData/Roaming/Subversion " (Windows 8) or other similar locations on other Windows versions. You need to changes servers file. AppData folder could be in hidden state, so you should make it showed. show hidden folder Open servers file using text editor like Notepad. open servers file Find [global] tag, and change proxy setting below it. configure proxy setting Hope it can be useful for you.