Nginx

Nginx como Proxy Reverso

# nginx.conf // Laraval example
server {
listen 80;
index index.php index.html;
root /var/www/html;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
charset utf-8;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass laravel:9000;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
location ~ /\.(?!well-known).* {
deny all;
}
}
# Dockerfile.prod // Laravel example
FROM nginx:1.15.0-alpine
RUN rm /etc/nginx/conf.d/default.conf
COPY nginx.conf /etc/nginx/conf.d
# Laravel example below
RUN mkdir /var/www/laravel/public -p && touch /var/www/laravel/public/index.php
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["nginx", "-g", "daemon off;"]

Rodando o container do nginx e editando o index.html

$ docker run --name nginx -d -p 8080:80 nginx
$ docker exec -it nginx bash
cd /usr/share/nginx/html
$ apt-get update
$ apt-get install vim
$ vim index.html
# Modo de edição: I
# Sair do modo de edição: Esc
# Salvar: Dois pontos + W