Created
January 25, 2018 10:18
-
-
Save salami-art/f7ea05ced0e1ca48689e231a41b79cb9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
upstream puma { | |
server unix:///home/ubuntu/apps/MyApp/shared/tmp/sockets/MyApp-puma.sock; | |
} | |
server { | |
listen 80 default_server deferred; | |
if ($http_user_agent ~* (banned|banned1|banned2)) { | |
return 403; | |
} | |
if ($http_user_agent == "-") { | |
return 403; | |
} | |
# server_name example.com; | |
root /home/ubuntu/apps/MyApp/current/public; | |
access_log /home/ubuntu/apps/MyApp/current/log/nginx.access.log; | |
error_log /home/ubuntu/apps/MyApp/current/log/nginx.error.log info; | |
location ^~ /public/ { | |
autoindex on; | |
alias /home/ubuntu/apps/MyApp/current/public/; | |
gzip_static on; | |
expires max; | |
add_header Cache-Control public; | |
} | |
try_files $uri/index.html $uri @puma; | |
location @puma { | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header Host $http_host; | |
proxy_redirect off; | |
proxy_pass http://puma; | |
} | |
error_page 500 502 503 504 /500.html; | |
client_max_body_size 10M; | |
keepalive_timeout 10; | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ wget http://example.com/path -O /dev/null --user-agent="banned" | |
http://example.com/path | |
Connecting to example.com:80... connected. | |
HTTP request sent, awaiting response... 200 OK |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment