grain.social is a photo sharing platform built on atproto.
1worker_processes 1;
2
3events {
4 worker_connections 1024;
5}
6
7http {
8 resolver [fdaa::3];
9 client_max_body_size 50M;
10
11 map $http_host $pds {
12 default http://grain-pds.internal:3000;
13 }
14
15 map $http_host $appview {
16 default http://atphoto.internal:8080;
17 }
18
19 map $http_host $darkroom {
20 default http://grain-darkroom.internal:8080;
21 }
22
23 map $http_upgrade $connection_upgrade {
24 default upgrade;
25 '' close;
26 }
27
28 server {
29 listen 80;
30 server_name *.grain.social;
31
32 if ($http_user_agent ~* "(AI2Bot|Ai2Bot\-Dolma|aiHitBot|Amazonbot|Andibot|anthropic\-ai|Applebot|Applebot\-Extended|bedrockbot|Brightbot\ 1\.0|Bytespider|CCBot|ChatGPT\-User|Claude\-SearchBot|Claude\-User|Claude\-Web|ClaudeBot|cohere\-ai|cohere\-training\-data\-crawler|Cotoyogi|Crawlspace|Diffbot|DuckAssistBot|EchoboxBot|FacebookBot|facebookexternalhit|Factset_spyderbot|FirecrawlAgent|FriendlyCrawler|Google\-CloudVertexBot|Google\-Extended|GoogleOther|GoogleOther\-Image|GoogleOther\-Video|GPTBot|iaskspider/2\.0|ICC\-Crawler|ImagesiftBot|img2dataset|ISSCyberRiskCrawler|Kangaroo\ Bot|meta\-externalagent|Meta\-ExternalAgent|meta\-externalfetcher|Meta\-ExternalFetcher|MistralAI\-User/1\.0|MyCentralAIScraperBot|NovaAct|OAI\-SearchBot|omgili|omgilibot|Operator|PanguBot|Panscient|panscient\.com|Perplexity\-User|PerplexityBot|PetalBot|PhindBot|Poseidon\ Research\ Crawler|QualifiedBot|QuillBot|quillbot\.com|SBIntuitionsBot|Scrapy|SemrushBot|SemrushBot\-BA|SemrushBot\-CT|SemrushBot\-OCOB|SemrushBot\-SI|SemrushBot\-SWA|Sidetrade\ indexer\ bot|TikTokSpider|Timpibot|VelenPublicWebCrawler|Webzio\-Extended|wpbot|YandexAdditional|YandexAdditionalBot|YouBot)") {
33 return 403;
34 }
35
36 location ~ ^/xrpc/social\.grain\.darkroom\..* {
37 proxy_pass $darkroom;
38 proxy_set_header Host $host;
39 proxy_set_header Upgrade $http_upgrade;
40 proxy_set_header Connection $connection_upgrade;
41 }
42
43 location ~ ^/xrpc/social\.grain\..* {
44 proxy_pass $appview;
45 proxy_set_header Host $host;
46 proxy_set_header Upgrade $http_upgrade;
47 proxy_set_header Connection $connection_upgrade;
48 }
49
50 location /xrpc {
51 proxy_pass $pds;
52 proxy_set_header Host $host;
53 proxy_set_header Upgrade $http_upgrade;
54 proxy_set_header Connection $connection_upgrade;
55 }
56
57 location = /.well-known/atproto-did {
58 proxy_pass $pds/.well-known/atproto-did;
59 proxy_set_header Host $host;
60 }
61
62 location / {
63 proxy_pass $appview;
64 proxy_set_header Host $host;
65 proxy_set_header Upgrade $http_upgrade;
66 proxy_set_header Connection $connection_upgrade;
67 }
68 }
69}