Skip to content

Commit

Permalink
feat: nginx conf
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfromyeg committed Dec 31, 2023
1 parent 67736e6 commit d63d1e4
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ server {
listen 80;
server_name api.bereal.michaeldemar.co;

# Redirect all HTTP traffic to HTTPS
return 301 https://$host$request_uri;
}

Expand All @@ -12,31 +13,33 @@ server {
ssl_certificate /etc/letsencrypt/live/api.bereal.michaeldemar.co/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/api.bereal.michaeldemar.co/privkey.pem;

# Block specific IP addresses
location / {
deny 144.255.17.181;
deny 171.34.179.120;
deny 222.94.163.44;
deny 171.116.44.119;
}

if ($http_referer ~* superlum.com) {
return 444;
}
# Block requests with "superlum.com" referrer
if ($http_referer ~* superlum.com) {
return 444;
}

if ($http_user_agent = "" || $request_method !~ ^(GET|HEAD|POST|PUT|DELETE|OPTIONS)$ ) {
return 403;
# Main server configuration
proxy_pass http://web:5000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}

# Drop requests to common WordPress paths
location ~* /(wp-admin|wp-login\.php|wp-includes|wp-content|xmlrpc\.php|wp-json) {
return 444;
}

# web and port are from the service's definition in docker-compose
location / {
proxy_pass http://web:5000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# Block non-standard HTTP methods
if ($request_method !~ ^(GET|HEAD|POST|PUT|DELETE|OPTIONS)$ ) {
return 403;
}
}

0 comments on commit d63d1e4

Please sign in to comment.