Skip to content

Commit 8a1916d

Browse files
authored
closes #12168 nginx reverse proxy opds (#12170)
* closes #12168 nginx reverse proxy opds * fix opds, add cors * Add CORS headers to /opds location
1 parent 58e45d9 commit 8a1916d

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

docker/web_nginx.conf

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,35 @@ server {
112112
return 429 '{"status": 429, "message": "Too Many Requests. Consider using https://openlibrary.org/developers/dumps."}';
113113
}
114114

115+
location /opds/ {
116+
proxy_pass https://ol-opds.prod.archive.org/;
117+
118+
add_header Access-Control-Allow-Origin "*" always;
119+
add_header Access-Control-Allow-Methods "GET, POST, OPTIONS" always;
120+
add_header Access-Control-Allow-Headers "Content-Type, Authorization" always;
121+
122+
# Handle preflight
123+
if ($request_method = OPTIONS) {
124+
return 204;
125+
}
126+
127+
add_header X-OPDS-Backend "ol-opds.prod.archive.org" always;
128+
proxy_ssl_server_name on;
129+
proxy_set_header Host ol-opds.prod.archive.org;
130+
proxy_set_header X-Forwarded-For $remote_addr;
131+
proxy_set_header X-Forwarded-Proto $scheme;
132+
133+
# optional but usually needed
134+
proxy_redirect off;
135+
}
136+
137+
location = /opds {
138+
add_header Access-Control-Allow-Origin "*" always;
139+
add_header Access-Control-Allow-Methods "GET, OPTIONS" always;
140+
add_header Access-Control-Allow-Headers "Content-Type" always;
141+
return 308 /opds/;
142+
}
143+
115144
location / {
116145
limit_req zone=web_limit burst=100 delay=10;
117146
limit_req zone=ua_rate_limit burst=25 delay=10;

0 commit comments

Comments
 (0)