Let's get started with using Nginx
The purpose of this post is to show how one can get up and running with a playground for Nginx.
This is not a toturial for usning Nginx.
(# TODO: Add ssh using uptime robot)
You'll need these ingredients to get up and running:
.devcontainer/devcontainer.json
{
"name": "nginx-playground",
"service": "dev-machine",
"dockerComposeFile": "docker-compose.yml",
"workspaceFolder": "/workspace",
"mounts": [
"source=${localWorkspaceFolder}/.devcontainer/.nginx,target=/usr/share/nginx/,type=bind"
],
"postStartCommand": "nginx"
}
.devcontainer/docker-compose.yml
name: nginx-playground-dc
services:
dev-machine:
build:
context: .
dockerfile: Dockerfile.nginx
volumes:
- ..:/workspace
networks:
- internal
ports:
- "8472:80"
command: ["sleep", "infinity"]
networks:
internal:
driver: bridge
.devcontainer/Dockerfile.nginx
FROM nginx:alpine
EXPOSE 80
.devcontainer/.nginx/html/index.html
<!DOCTYPE html>
<body>Hello</body>
</html>
.devcontainer/.nginx/nginx.conf/nginx.conf
events {}
http {
server {
listen 80;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
}
location /nginx_status {
stub_status on;
allow 127.0.0.1; # Restrict access to localhost for security
deny all;
}
Now run that devcontainer and open a browser on your host machine:
Or from the host machines terminal run:
curl http://localhost:8472
Top comments (0)