Configure Nginx reverse proxy with SSL in Ubuntu

The steps to configure Nginx reverse proxy in Ubuntu are as follows

1. Install nginx
sudo apt-get install nginx
sudo service nginx start
sudo chkconfig nginx on

2. Go to nginx config file directory
cd /etc/nginx/

3. backup current nginx config file
mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf-back

4. Create a new config file with the following content
vim /etc/nginx/nginx.conf
# For more information on configuration, see:
# * Official English Documentation:
# * Official Russian Documentation:

#user nginx;
user www-data;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /var/run/;

events {
worker_connections 1024;

http {
log_format main ‘$remote_addr – $remote_user [$time_local] “$request” ‘
‘$status $body_bytes_sent “$http_referer” ‘
‘”$http_user_agent” “$http_x_forwarded_for”‘;

access_log /var/log/nginx/access.log main;

sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;

include /etc/nginx/mime.types;
default_type application/octet-stream;

# Load modular configuration files from the /etc/nginx/conf.d directory.
# See
# for more information.
include /etc/nginx/conf.d/*.conf;

index index.html index.htm;


5. enable reverse proxy
cd /etc/nginx/conf.d
vim example.conf
server {
listen 80;
listen 443 ssl;
ssl_certificate /etc/letsencrypt/live/;
ssl_certificate_key /etc/letsencrypt/live/;

location / {

6. Check if the configurations are correct

nginx configtest


nginx -t

If there is no errors in the configuration, restart nginx

service nginx restart

Post navigation

Alvin Jaison

Myself Alvin Jaison. I'm a DevOps Engineer by Profession; A Mountaineer by Passion. I started this website to share DevOps related posts. Post your suggestions as a comment. You can reach me @

Leave a Reply

Your email address will not be published. Required fields are marked *