NGINX
Installation
Ubuntu: apt-get install nginx
CentOS: yum install nginx
Docker: docker pull nginx
Building NGINX in Docker
Configuration
Two server block, serving static files
http {
index index.html;
server {
server_name www.domain1.com;
access_log logs/domain1.access.log main;
root /var/www/domain1.com/htdocs;
}
server {
server_name www.domain2.com;
access_log logs/domain2.access.log main;
root /var/www/domain2.com/htdocs;
}
}Default Catch All Server Block
Wildcard subdomain
Reverse Proxy with Caching
SSL Certificate
Prevent accessing default page using ip
Return inline html
Block to root, but allow to specific file
Some Errors
Docker: Cannot load certificate when specifiying certificate in same folder: ssl_certificate cert.crt
In fact host volume is /etc/nginx mapping to /etc/nginx/conf.d
Solution: use ssl_certificate /etc/nginx/conf.d/cert.crt
“http” directive is not allowed here in
Reason: there are http in parent configuration and this configuration is included in that one
Solution: remove http {} section from mentioned configuration file
Reference
https://www.freecodecamp.org/news/the-nginx-handbook/
https://www.nginx.com/resources/wiki/start/
NGINX with LDAP Authentication: https://www.nginx.com/blog/nginx-plus-authenticate-users/
HTTP Load Balancer: https://docs.nginx.com/nginx/admin-guide/load-balancer/http-load-balancer/
https://my.godaddy.com/help/nginx-on-centos-7-install-a-certificate-27192
https://www.nginx.com/blog/secure-distribution-ssl-private-keys-nginx/
NGINX Tutorial: https://www.javatpoint.com/nginx-tutorial
Last updated