📑

DockerでNginxとApacheを起動

1 min read

DockerでNginxとApacheを利用する際に毎回忘れてしまっているのでメモ用記事

Nginx

docker-compose.yml
version: '3'

services:
  nginx:
    image: nginx:latest
    ports:
      - "80:80"
    volumes:
      - ./default.conf:/etc/nginx/conf.d/default.conf
      - ./public:/var/www/html
      - ./log:/var/log/nginx
default.conf
server {
    listen 80;
    server_name _;

    root  /var/www/html;
    index index.html;
}

Apache

docker-compose.yml
version: '3'

services:
  apache:
    image: httpd:2.4
    ports:
      - "80:80"
    volumes:
      - ./httpd.conf:/usr/local/apache2/conf/httpd.conf
      - ./log:/var/log/httpd
      - ./public:/var/www/html
httpd.conf
Listen 80
ServerName localhost:80

LoadModule mpm_event_module modules/mod_mpm_event.so
LoadModule authz_core_module modules/mod_authz_core.so

LoadModule unixd_module modules/mod_unixd.so

LoadModule log_config_module modules/mod_log_config.so

User daemon
Group daemon

LogFormat "%h %l %u %t \"%r\" %>s %b" common
CustomLog /var/log/httpd/access.log common
ErrorLog /var/log/httpd/error.log

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so

DocumentRoot "/var/www/html"

ProxyPass /api http://host.docker.internal:8080
ProxyPassReverse /api http://host.docker.internal:8080