Skip to content

Commit

Permalink
[nginx] improve nginx routing and caching
Browse files Browse the repository at this point in the history
  • Loading branch information
capcom6 committed Oct 30, 2024
1 parent a1fb301 commit 1c4d09e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ IMAGE_NAME ?= capcom6/android-sms-gateway-docs
CONTAINER_NAME ?= android-sms-gateway-docs

# Set the port to expose on the host
HOST_PORT ?= 8000
HOST_PORT ?= 8080

# Makefile targets
.PHONY: build run stop clean
Expand All @@ -19,16 +19,16 @@ build:
docker build -t $(IMAGE_NAME) .

# Run the Docker container
run:
docker run --name $(CONTAINER_NAME) -d -p $(HOST_PORT):80 $(IMAGE_NAME)
run: build
docker run --rm --name $(CONTAINER_NAME) -p $(HOST_PORT):80 $(IMAGE_NAME)

# Stop and remove the Docker container
stop:
docker stop $(CONTAINER_NAME)
docker rm $(CONTAINER_NAME)

# Remove the Docker image
clean:
clean: stop
docker rmi $(IMAGE_NAME)

# Rebuild the Docker image
Expand Down
3 changes: 3 additions & 0 deletions docs/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
User-agent: *
Allow: /
Sitemap: https://sms-gate.app/sitemap.xml
17 changes: 9 additions & 8 deletions nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ server {
set_real_ip_from 10.0.0.0/8;
real_ip_header X-Forwarded-For;

root /usr/share/nginx/html;

location / {
root /usr/share/nginx/html;
index index.html;
try_files $uri $uri/ =404;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}

# Disable logging for favicon
Expand All @@ -17,11 +18,11 @@ server {
}

# Optimize serving static files
# location ~* \.(?:css|js|svg|gif|png|jpg|jpeg|webp)$ {
# expires 1y;
# access_log off;
# add_header Cache-Control "public";
# }
location ~* \.(?:css|js|svg|gif|png|jpg|jpeg|webp)$ {
expires 1y;
access_log off;
add_header Cache-Control "public";
}

# Gzip Compression
gzip on;
Expand Down

0 comments on commit 1c4d09e

Please sign in to comment.