mirror of
https://github.com/Fechin/reference.git
synced 2026-11-21 21:44:45 +03:00
Update Dockerfile and nginx.conf to use nginx and add redirect rules
This commit is contained in:
1 parent
535ec91929
commit
ffb15b706b
2 files changed
+56
-11
No files matched your search
+10
-11
@@ -1,18 +1,17 @@
|
||||
FROM alpine:latest
|
||||
FROM nginx:1.23.3-alpine
|
||||
|
||||
# Install thttpd
|
||||
RUN apk add --no-cache thttpd
|
||||
# Remove the default Nginx configuration
|
||||
RUN rm -rf /etc/nginx/conf.d/
|
||||
|
||||
# Create a non-root user to own the files and run our server
|
||||
RUN adduser -D static
|
||||
USER static
|
||||
WORKDIR /home/static
|
||||
# Copy our Nginx configuration
|
||||
COPY nginx.conf /etc/nginx/
|
||||
|
||||
# Copy the static website
|
||||
# Use the .dockerignore file to control what ends up inside the image!
|
||||
COPY public .
|
||||
COPY public /usr/share/nginx/html/
|
||||
|
||||
# Run thttpd
|
||||
CMD ["thttpd", "-D", "-h", "0.0.0.0", "-p", "3000", "-d", "/home/static", "-u", "static", "-l", "-", "-M", "60"]
|
||||
# Expose port 80
|
||||
EXPOSE 3000
|
||||
|
||||
EXPOSE 3000
|
||||
# Start Nginx
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
user nginx;
|
||||
worker_processes auto;
|
||||
|
||||
error_log /var/log/nginx/error.log notice;
|
||||
pid /var/run/nginx.pid;
|
||||
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
access_log /var/log/nginx/access.log ;
|
||||
error_log /var/log/nginx/error.log;
|
||||
|
||||
sendfile on;
|
||||
#tcp_nopush on;
|
||||
|
||||
keepalive_timeout 65;
|
||||
|
||||
server {
|
||||
listen 3000;
|
||||
listen [::]:3000;
|
||||
|
||||
server_name localhost;
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
# error_page
|
||||
error_page 404 403 500 502 503 504 /assets/page/oops.htm;
|
||||
|
||||
# Rename cheatsheet
|
||||
rewrite ^/golang$ /go permanent;
|
||||
|
||||
# remove .html extension
|
||||
location / {
|
||||
if ($request_uri ~ ^/(.*)\.html) {
|
||||
return 302 /$1;
|
||||
}
|
||||
try_files $uri $uri.html $uri/ =404;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user