srcmesh-workshop / docker-workshop

0 stars 40 forks source link

朱淑華-USER-4作業 #8

Open angwachu opened 3 days ago

angwachu commented 3 days ago

compose.yaml services: nginx: image: nginx:latest container_name: user4-nginx ports:

volumes: wordpress: db:

ngnix.conf file

user nginx; worker_processes 1;

error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid;

events { worker_connections 1024; }

http { log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"';

# Path to access.log & error.log
access_log /var/log/nginx/access.log  main;
error_log /var/log/nginx/error.log  warn;

sendfile        on;
keepalive_timeout  65;
gzip  on;

upstream backend {
    # must match the target service name
    server wordpress:80;
}

server {
    listen       80;
    location / {
        # $http_host is the host name that users seen on the browser URL
        # and it equals to `HTTP_HOST` request header.
        proxy_set_header Host $http_host;

        # You have to change this according to your setup.
        proxy_pass http://wordpress;

        # Modify `Location` of 301 or 302 HTTP response, so
        # that the browser will follow the correct location.
        proxy_redirect ~^http://[^/]*/(.*) http://$http_host/$1;
    }
}

}

angwachu commented 3 days ago

user-4.compose.yaml.txt

angwachu commented 3 days ago

nginx.conf.txt