Update setup script to include static subdomain and refine Nginx configuration for service routing
This commit is contained in:
parent
b647c5f014
commit
57e6c3893d
2
setup.sh
2
setup.sh
@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
SUBDOMAINS=(
|
||||
"whaffman.42.fr" "mail.whaffman.42.fr" "adminer.whaffman.42.fr" "ftp.whaffman.42.fr")
|
||||
"whaffman.42.fr" "mail.whaffman.42.fr" "adminer.whaffman.42.fr" "ftp.whaffman.42.fr" "static.whaffman.42.fr")
|
||||
HOSTS_FILE="/etc/hosts"
|
||||
IP="127.0.0.1"
|
||||
|
||||
|
||||
@ -11,8 +11,6 @@ ENV GOPATH /go
|
||||
ENV PATH /go/bin:$PATH
|
||||
|
||||
RUN mkdir -p ${GOPATH}/src ${GOPATH}/bin
|
||||
ENV GOTOOLCHAIN=auto
|
||||
|
||||
|
||||
RUN go install github.com/mailhog/MailHog@latest
|
||||
|
||||
|
||||
@ -12,7 +12,7 @@ if [ "$1" = 'mysqld' ] && [ ! -d "/var/lib/mysql/mysql" ]; then
|
||||
mysql -e "CREATE USER '${MYSQL_USER}'@'%' IDENTIFIED BY '${MYSQL_PASSWORD}';" && \
|
||||
mysql -e "GRANT ALL PRIVILEGES ON \`${MYSQL_DATABASE}\`.* TO '${MYSQL_USER}'@'%';"
|
||||
mysql -e "FLUSH PRIVILEGES;"
|
||||
[ -f "/usr/bin/local/init.sql" ] && mysql "${MYSQL_DATABASE}" < /usr/bin/local/init.sql
|
||||
# [ -f "/usr/bin/local/init.sql" ] && mysql "${MYSQL_DATABASE}" < /usr/bin/local/init.sql
|
||||
kill "$pid" && wait "$pid"
|
||||
fi
|
||||
|
||||
|
||||
@ -14,6 +14,7 @@ RUN openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
|
||||
-subj "/CN=*.${DOMAIN_NAME}"
|
||||
|
||||
COPY ./conf/nginx.conf /etc/nginx/nginx.conf
|
||||
RUN sed -i "s/\${DOMAIN_NAME}/${DOMAIN_NAME}/g" /etc/nginx/nginx.conf
|
||||
EXPOSE 443 8443
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
HEALTHCHECK --interval=5s --timeout=3s --start-period=5s --retries=1 \
|
||||
|
||||
@ -5,55 +5,13 @@ events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
server {
|
||||
listen 443 ssl;
|
||||
server_name ${DOMAIN_NAME};
|
||||
|
||||
ssl_certificate /etc/ssl/certs/nginx-selfsigned.crt;
|
||||
ssl_certificate_key /etc/ssl/private/nginx-selfsigned.key;
|
||||
|
||||
root /var/www/html;
|
||||
|
||||
access_log /var/log/nginx/example.localhost-access.log;
|
||||
error_log /var/log/nginx/example.localhost-error.log error;
|
||||
index index.html index.htm index.php;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.php$is_args$args;
|
||||
}
|
||||
|
||||
location ~ /adminer\.php$ {
|
||||
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
||||
fastcgi_pass adminer:9000;
|
||||
fastcgi_index adminer.php;
|
||||
include fastcgi.conf;
|
||||
}
|
||||
|
||||
location ~ \.php$ {
|
||||
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
||||
fastcgi_pass wordpress:9000;
|
||||
fastcgi_index index.php;
|
||||
include fastcgi.conf;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
server {
|
||||
listen 8080;
|
||||
server_name ${DOMAIN_NAME};
|
||||
location / {
|
||||
proxy_pass http://static-site:80;
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen 8443 ssl;
|
||||
server_name ${DOMAIN_NAME};
|
||||
listen 443 ssl;
|
||||
server_name mail.${DOMAIN_NAME};
|
||||
|
||||
ssl_certificate /etc/ssl/certs/nginx-selfsigned.crt;
|
||||
ssl_certificate_key /etc/ssl/private/nginx-selfsigned.key;
|
||||
@ -74,5 +32,52 @@ http {
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl;
|
||||
server_name adminer.${DOMAIN_NAME};
|
||||
|
||||
ssl_certificate /etc/ssl/certs/nginx-selfsigned.crt;
|
||||
ssl_certificate_key /etc/ssl/private/nginx-selfsigned.key;
|
||||
|
||||
location / {
|
||||
fastcgi_pass adminer:9000;
|
||||
fastcgi_param SCRIPT_FILENAME /var/www/html/adminer.php;
|
||||
include fastcgi_params;
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl;
|
||||
server_name static.${DOMAIN_NAME};
|
||||
|
||||
ssl_certificate /etc/ssl/certs/nginx-selfsigned.crt;
|
||||
ssl_certificate_key /etc/ssl/private/nginx-selfsigned.key;
|
||||
|
||||
location / {
|
||||
proxy_pass http://static-site:80;
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl;
|
||||
server_name ${DOMAIN_NAME};
|
||||
|
||||
ssl_certificate /etc/ssl/certs/nginx-selfsigned.crt;
|
||||
ssl_certificate_key /etc/ssl/private/nginx-selfsigned.key;
|
||||
|
||||
root /var/www/html;
|
||||
|
||||
index index.html index.htm index.php;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.php$is_args$args;
|
||||
}
|
||||
|
||||
location ~ \.php$ {
|
||||
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
||||
fastcgi_pass wordpress:9000;
|
||||
fastcgi_index index.php;
|
||||
include fastcgi.conf;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -46,7 +46,7 @@
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<img src="./42_Logo.svg" alt="42 Logo" style="height: 100px; margin-bottom: 20px;">
|
||||
<img src="./42_logo.svg" alt="42 Logo" style="height: 100px; margin-bottom: 20px;">
|
||||
<h1>Welcome to whaffman.42.fr</h1>
|
||||
<h2>Available Services</h2>
|
||||
<ul class="services-list">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user