Coder Social home page Coder Social logo

static-site's Introduction

static-site

Static HTML site for Docker nginx

How to Run this inside Docker?

  • One Dockerfile for Docker build

  • nginx.conf file with nginx configurations

  • then:docker build .-t <YOUR_BUILD_TAG> to build the image

  • finally to run docker run -t <YOUR_BUILD_TAG>

  • Create a Dockerfile with following content Dockerfile

FROM nginx:latest

# Copy custom configuration file from the current directory

COPY nginx.conf /etc/nginx/nginx.conf

RUN mkdir -p /data/www

COPY index.html /data/www/index.html
COPY 404.html /data/www/404.html
COPY . /data/www

then created configuration file for Nginx: nginx.conf

user  nginx;
worker_processes  1;
error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
}

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;
    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;
    keepalive_timeout  1024;
    #gzip  on;

    server {
        listen 80 default_server;
        listen [::]:80 default_server;
        location /health {
            access_log off;
            return  200;
        }

        if ($http_x_forwarded_proto = 'http') {
           return 301 https://$host$request_uri;
        }

        location / {
            root   /data/www;
            index  index.html;
            try_files $uri $uri/ /index.html;
        }
    }
}

static-site's People

Contributors

ravishtiwari avatar albertlovescloud avatar

Watchers

James Cloos avatar

Forkers

guptaravi540

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.