Skip to content

Latest commit

 

History

History
101 lines (73 loc) · 1.75 KB

nginx.md

File metadata and controls

101 lines (73 loc) · 1.75 KB

Nginx

Table of context

Configuration files

vim /etc/nginx/nginx.conf   # Default config file
cd /etc/nginx/conf.d        # Additional config files

Static website

Create config file for a domain:

cd /etc/nginx/conf.d
sudo vim sub.domain.ru.conf

Example of a config file:

server {
  server_name sub.domain.ru;
  location / {
    root /var/www/sub.domain.folder;
  }
}

Test config files and restart Nginx:

sudo nginx -t
sudo systemctl restart nginx

Reverse proxy

Create config file for a domain:

cd /etc/nginx/conf.d
sudo vim sub.domain.ru.conf

Example of a config file:

server  {
  server_name sub.domain.ru;
  location / {
    proxy_pass http://localhost:5000;
  }
}

Test config files and restart Nginx:

sudo nginx -t
sudo systemctl restart nginx

↑ NGINX Reverse Proxy.

HTML files

cd /var/www/
cd /usr/share/nginx/html/

Load balancing

↑ NGINX as a load balancer.

↑ HTTP Load Balancing.

Permanent redirect from one page to another

server {
  rewrite ^/old/url$ https://new.domain.ru/old/url permanent;
}

Links

↑ Beginner's Guide.