IP Canonicalization in Nginx Http/Https

Nginx, SEO
IP Canonicalization in Nginx Http/Https: IP canonicalization is to redirect IP Address to the domain. This actually a part of SEO, so good to have IP canonicalization, but you can't achieve this using shared web hosting. IP Canonicalization in Nginx Http/Https: Add the below block to above of your default server block in your nginx conf file, which is default available in /etc/nginx/nginx.conf This below block works for both http and https IP canonicalization in nginx server. [code] server { listen *:80; listen *:443 ssl http2; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_certificate "/etc/letsencrypt/live/ngdeveloper.com/fullchain.pem"; ssl_certificate_key "/etc/letsencrypt/live/ngdeveloper.com/privkey.pem"; server_name 18.218.X.X; return 301 https://ngdeveloper.com; } ...

Fix for AWS SSH Connection Hangs ?

Java
Fix for AWS SSH Connection Hangs ? You could have not added the SSH TCP connection to your ec2 instance, thay may be creating this issue aws SSH connection Hangs issue. Follow the simple 3 steps to get away from this, 1. Login to AWS EC2 Console and click on Security Groups (available in the left sidebar). 2. Select your EC2 instance's security group then click on the Inbound tab. 3. Now add the SSH Rule like this to resolve this issue,

Steps to Increase AWS Disk Size

AWS
Steps to Increase AWS Disk Size 1. Login to AWS Console 2. Click EC2 and navigate to your currently running instances. 3. Click the instance and note down your Root device and Block Device 4. Click on Block Devices then click EBS ID to navigate to your volume page. In other way, you can directly click the volumes under Elastic Block Storage and reach the same page:   5. Click the Actions -> Modify Volume and Increase the size then click yes to confirm. 6. Login to your aws console through SSH and Run lsblk command and note down the volumn names Here, xvda is the recently changed volume size ` - xvdal previous size, 50G, we are trying to increase the size from 50GB to 80GB in this case.   If you run df -h now you will be able...

How to install MySQL in Docker ?

Docker
How to install MySQL in Docker ? Installing Particular Version [code] sudo docker pull mysql/mysql-server:5.7 [/code]   Installing Latest Version [code] sudo docker pull mysql [/code]   Running MySql Docker Image: [code] sudo docker run --name mysqlcname -e MYSQL_ROOT_PASSWORD=root -p 3306:3306 --restart always -d mysql [/code] -d => to start it automatically when the server started.     Docker useful commands for Beginners: You can also find other useful docker commands here.
Spring Boot Docker Deployment Steps

Spring Boot Docker Deployment Steps

Docker
Spring Boot Docker Deployment Steps Pre requisite: Install Java. [code] sudo yum install java-1.8.0 sudo yum remove java-1.7.0-openjdk [/code] Install Maven [code] sdk install maven [/code] Note: SDKMan can be used to install the maven. Spring Boot Jar - Docker Deployment Steps: Step 1: Create some folder in your linux machine.[create build folder inside /var] Step 2: Docker deployment file creation Create the below content as Dockerfile: [Filename: Dockerfile without any extension and must be available in "/var/build" path] [code] FROM openjdk:8-jdk-alpine VOLUME /tmp COPY yourjarname-1.0 yourjarname.jar ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/yourjarname.jar"] [/code] Here yourjarname-1.0 is assumed like the ...

How to add canonical link to all routers in Angular 7?

Angular, Articles
How to add canonical link to all routers in Angular 7? When I was trying to find a snippet on how to add canonical link to all routers in Angular 7, I was able to find out lot of snippets in stackoverflow, github and few other blogs. But When I tested all the snippets from both stackoverflow and github, below snippet is the one which is working properly without any issues in all the use cases. Few issues I observed with other snippets: When ever navigation is happened it is keep on adding the canonical link tags, this below snippet just keeps only one canonical link tag. Duplicate canonical link tags added due to above point 1, this below snippet uses update method which always removes and adds the canonical link tag, so this helps to keep only one canonical link tag. No update/remove to...
Letsencrypt commands for beginners

Letsencrypt commands for beginners

Articles, Tools
Letsencrypt commands for beginners ./certbot-auto certificates: This commands lists down all the letsencrypt certificates (both active and expired) with exact path details where the certificate exists. ./certbot-auto certonly -a standalone: This command helps to create a new ssl certificate, if you want to create for more than one domain then enter the domain names with comma. ./letsencrypt-auto renew: This command renews all your existing letsencrypt certificates. This blog explain in detail about the letsencrypt certificate renewal process and stuffs. ./certbot-auto delete: This will list down the certificates installed and asks the prompt for certificate deletion. cd /letsencrypt/letsencrypt: Default path in centos/AWS machines, once the letsencrypt is installed. ./let...
Mockito for beginners

Mockito for beginners

Frameworks
Mockito for beginners: Mockito is an open source testing framework, and it is a widely used for junit testing with mocking beans/repositories in frameworks such as spring mvc & spring boot. The framework allows the creation of test double objects in automated unit tests for the purpose of test-driven development or behavior-driven development. The framework's name and logo are a play on mojitos, a type of drink. How to Mock void method ? doNothing().when(couponRepository).deleteAll(Mockito.any()); Note: deleteAll is a void method.   How to Mock public methods of a same class ? NgDeveloper ngDeveloperSpy = Mockito.spy(new NgDeveloper()); when(ngDeveloperSpy.getAuthor()).thenReturn("Mirthbees"); Note:¬†getAuthor() is the public method which we need to mock, so we have
Creating a SOAP web service with Spring Boot

Creating a SOAP web service with Spring Boot

Spring Boot, Web Services
Creating a SOAP web service with Spring Boot Main Application Spring Boot File: [java] package com.ngdeveloper; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class CouponApplication { public static void main(String[] args) { SpringApplication.run(CouponApplication.class, args); } } [/java] pom.xml file: This below pom.xml file contains the plugin to generate the output directory files from the xsd file, so create the pom.xml, xsd file, endpoints then by starting your spring boot application you will be able to find the other required files generated. These are the files will be generated automatically with this heading info, [plain] // // This file was g...

2 ways to refer classpath resource in spring boot projects

Spring Boot
2 ways to refer classpath resource in spring boot projects   Using ClasspathResource [java] import org.springframework.core.io.ClassPathResource; @Bean public XsdSchema mySchema() { return new SimpleXsdSchema(new ClassPathResource("myfile.xsd")); } [/java]   Note: Here myfile.xsd should be located in src/main/resources. Using Resource [java] import org.springframework.core.io.Resource; @Value("classpath:myfile.xsd") private Resource res; @Bean public XsdSchema mySchema() { return new SimpleXsdSchema(res); } [/java]