Sign inSign up

shinejh0528/nginx

By shinejh0528

•Updated about 1 year ago

nginx

Image
Internet of things
0

10K+

shinejh0528/nginx repository overview

⁠How to use



⁠1. Run nginx container
⁠data_dir is to change config and log file path. If container killed for some reason, then you can't check log if you don't change the log file path.
⁠nginx_config : nginx fonfig path environment. if you don't use this option, then the config path set as default path.
⁠nginx_sa : nginx site-available path environment. if you don't use this option, then the config path set as default path.
⁠80 port is for http, 443 port is for https.
docker run -itd -v [data_dir]:[data_dir] -p 80:80 -p 443:443 -e nginx_config=[path_to]/nginx.conf -e nginx_sa=[sa_path] --name [name] shinejh0528/nginx:1.1.0
⁠


⁠Useful content

⁠Connect to container using exec

docker exec -it [name] /bin/bash
⁠

⁠nginx config file

⁠default path is
/etc/nginx/sites-available/default
⁠
⁠config file ex)
⁠This example is to constitute reverse proxy domain for 2 port
⁠proxy_pass
server {
    listen 80;
    server_name xxx1.com;

    location / {
        proxy_pass http://172.17.0.1:8080;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

server {
    listen 80;
    server_name xxx2.com;

    location / {
        proxy_pass http://172.17.0.1:8088;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

server {
    listen 443 ssl;
    server_name xxx2.com;

    # SSL
    ssl_certificate [path].pem;
    ssl_certificate_key [path].key;

    # SSL Protocols Configuration
    ssl_protocols TLSv1.2 TLSv1.3;

    # Cipher Suite Configuration
    ssl_prefer_server_ciphers on;
    ssl_ciphers HIGH:!aNULL:!MD5;

    location / {
        proxy_pass https://172.17.0.1:8088;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}
⁠

⁠nginx config file

⁠Default path is
/etc/nginx/nginx.conf
⁠

⁠Log file

⁠Find access_log, error_log and edit nginx config like this
access_log /data/nginx/log/access.log;
error_log /data/nginx/log/error.log;
⁠

⁠nginx restart

service nginx restart

Tag summary

Content type

Image

Digest

sha256:9f061241a…

Size

141.4 MB

Last updated

about 1 year ago

docker pull shinejh0528/nginx:1.2.0