How to Configure a Nginx Reverse Proxy With Let's Encrypt

Let’s say one of your micro services is running on http://localhost:3000

If you already have a nginx service running on the server, create a server block like this:

1
vim /etc/nginx/sites-available/domain.com.conf

Grab this content to paste in:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
server {

  server_name domain.com;

  root /var/www/html;
  index index.html;

  location / {
    proxy_pass http://localhost:3000;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Host $host;
    proxy_cache_bypass $http_upgrade;
  }

}

For more advanced (more so production ready) configuration, use below instead:

How to Use Git Rebase in a Practical Situation

Let’s say there are two pull requests open on a project repository.

Each change has its own branch like this:

  • master
  • feature/add-base64-endpoint
  • feature/add-user-agent-endpoint

The challenge is to use git rebase to add both changes to master. When you finished, your master branch should have three commits in the following order:

  • feat: add user-agent endpoint
  • feat: add base64 endpoint
  • init

Okay, let’s go!

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
git clone repo_url
git status
git checkout feature/add-base64-endpoint
git rebase master
git status
git checkout master
git merge feature/add-base64-endpoint
git status
git checkout feature/add-user-agent-endpoint
git rebase master

Oops! You now see rebase conflict!

How to Enable Login with Password on Linux

Let’s update the Password Authentication parameter in the ssh service config file:

1
vim /etc/ssh/sshd_config

Wait, what? I can’t even find the sshd service?

Install it then:

1
2
sudo apt update
sudo apt install openssh-server

In the /etc/ssh/sshd_config file, uncomment this line:

1
#PasswordAuthentication yes

Done.

Oops! Don’t forget to reboot! 🙂

Or just run:

How to Update Apt Repository on Kali Linux

Back up the current sources.list first.

1
sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup

Well, run this command then.

1
sudo echo "deb http://http.kali.org/kali kali-rolling main non-free contrib" > /etc/apt/sources.list

Now you can run apt update command!

Happy networking! 😎

How to Dockerize a Full Stack MEVN Application

First things first. Let’s check the directory structure of the app.

A Full Stack MEVN Application

A Full Stack MEVN Application

Let’s take a look into the DB image first.

1
2
3
4
5
6
7
8
9
FROM mongo:latest

WORKDIR /app
COPY . /app

ENV MONGO_INITDB_ROOT_USERNAME=root
ENV MONGO_INITDB_ROOT_PASSWORD=password

EXPOSE 27017

I thought importing dump data should be working if I used CMD or ENTRYPOINT.