Skip to content

Commit

Permalink
Merge pull request #18 from europeana/EA-3218_fix_gateway_issues
Browse files Browse the repository at this point in the history
EA-3218 Forward requests over https
  • Loading branch information
P-Ehlert committed Oct 27, 2022
2 parents 5c5fc0f + dae6833 commit 01cf42b
Showing 1 changed file with 29 additions and 29 deletions.
58 changes: 29 additions & 29 deletions nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -28,46 +28,46 @@ http {

upstream search_api {
keepalive 10;
server {{env "SEARCH_API_HOST"}};
server {{env "SEARCH_API_HOST"}}:443;
}
upstream thumbnail_api {
keepalive 10;
server {{env "THUMBNAIL_API_HOST"}};
server {{env "THUMBNAIL_API_HOST"}}:443;
}
upstream oai_record {
keepalive 10;
server {{env "OAI_RECORD_HOST"}};
server {{env "OAI_RECORD_HOST"}}:443;
}
upstream annotation_api {
keepalive 10;
server {{env "ANNOTATION_API_HOST"}};
server {{env "ANNOTATION_API_HOST"}}:443;
}
upstream entity_api {
keepalive 10;
server {{env "ENTITY_API_HOST"}};
server {{env "ENTITY_API_HOST"}}:443;
}

upstream entity_management {
keepalive 10;
server {{env "ENTITY_MANAGEMENT_HOST"}};
server {{env "ENTITY_MANAGEMENT_HOST"}}:443;
}

upstream manifest_api {
keepalive 10;
server {{env "MANIFEST_API_HOST"}};
server {{env "MANIFEST_API_HOST"}}:443;
}
upstream fulltext_api {
keepalive 10;
server {{env "FULLTEXT_API_HOST"}};
server {{env "FULLTEXT_API_HOST"}}:443;
}
upstream set_api {
keepalive 10;
server {{env "SET_API_HOST"}};
server {{env "SET_API_HOST"}}:443;
}

upstream recommendation_api {
keepalive 10;
server {{env "RECOMMENDATION_API_HOST"}};
server {{env "RECOMMENDATION_API_HOST"}}:443;
}

server {
Expand Down Expand Up @@ -106,7 +106,7 @@ http {
location ~ ^/api/(.*) {
rewrite ^/api/(.*)$ /api/$1 break;
proxy_set_header Host {{env "SEARCH_API_HOST"}};
proxy_pass http://search_api;
proxy_pass https://search_api;
}


Expand Down Expand Up @@ -142,45 +142,45 @@ http {
# Recommendation API (alternative path, has to be defined before Search & Record)
location ~ ^/record/(v2/)?(.*)/recommend {
proxy_set_header Host {{env "RECOMMENDATION_API_HOST"}};
proxy_pass http://recommendation_api/recommend/record/$2$is_args$args;
proxy_pass https://recommendation_api/recommend/record/$2$is_args$args;
}

# Search API
location ~ ^/record/(v2/)?(open)?search(.*) {
rewrite ^/record/(v2/)?(open)?search(.*)$ /api/v2/$2search$3 break;
proxy_set_header Host {{env "SEARCH_API_HOST"}};
proxy_pass http://search_api;
proxy_pass https://search_api;
}

# Record API
location ~ ^/record/(v2/)?(.*) {
rewrite ^/record/(v2/)?(.*)$ /api/v2/record/$2 break;
proxy_set_header Host {{env "SEARCH_API_HOST"}};
proxy_pass http://search_api;
proxy_pass https://search_api;
}

# Always enable CORS for Search & Record API Swagger endpoint (as bug fix)
location = /record/api-docs {
proxy_set_header Host {{env "SEARCH_API_HOST"}};
proxy_hide_header Access-Control-Allow-Origin;
add_header Access-Control-Allow-Origin "*";
proxy_pass http://search_api/api/api-docs;
proxy_pass https://search_api/api/api-docs;
}

# Thumbnail API v2 (old style)
location = /api/v2/thumbnail-by-url.json {
# Thumbnails are JPEGs; no need to gzip them
gzip off;
proxy_set_header Host {{env "THUMBNAIL_API_HOST"}};
proxy_pass http://thumbnail_api;
proxy_pass https://thumbnail_api;
}

# Thumbnail API v2 (new style)
location = /thumbnail/v2/url.json {
# Thumbnails are JPEGs; no need to gzip them
gzip off;
proxy_set_header Host {{env "THUMBNAIL_API_HOST"}};
proxy_pass http://thumbnail_api/api/v2/thumbnail-by-url.json;
proxy_pass https://thumbnail_api/api/v2/thumbnail-by-url.json;
}

location ~ /thumbnail/v2/(.*) {
Expand All @@ -193,19 +193,19 @@ http {
# Thumbnails are JPEGs; no need to gzip them
gzip off;
proxy_set_header Host {{env "THUMBNAIL_API_HOST"}};
proxy_pass http://thumbnail_api/thumbnail/v3/$2$is_args$args;
proxy_pass https://thumbnail_api/thumbnail/v3/$2$is_args$args;
}

# OAI-PMH requests
location = /oai/record {
proxy_set_header Host {{env "OAI_RECORD_HOST"}};
proxy_pass http://oai_record/oai/$is_args$args;
proxy_pass https://oai_record/oai/$is_args$args;
}

# OAI-PMH index page
location = /oai/record/ {
proxy_set_header Host {{env "OAI_RECORD_HOST"}};
proxy_pass http://oai_record/index.html;
proxy_pass https://oai_record/index.html;
}

# Change all OAI-PMH .shtml form pages to .html
Expand All @@ -216,55 +216,55 @@ http {
# OAI-PMH query forms
location ~ ^/oai/record/(.*)\.html {
proxy_set_header Host {{env "OAI_RECORD_HOST"}};
proxy_pass http://oai_record/$1.html;
proxy_pass https://oai_record/$1.html;
}

# Annotation API
location ~ ^/annotation/(.*) {
proxy_set_header Host {{env "ANNOTATION_API_HOST"}};
proxy_pass http://annotation_api/annotation/$1$is_args$args;
proxy_pass https://annotation_api/annotation/$1$is_args$args;
}

# Entity - search, resolve and suggest are routed to Entity API
location ~ ^/entity/(search|suggest|resolve|enrich|stats)(.*) {
proxy_set_header Host {{env "ENTITY_API_HOST"}};
proxy_pass http://entity_api/entity/$1$2$is_args$args;
proxy_pass https://entity_api/entity/$1$2$is_args$args;
}

# Entity - all other requests go to Entity Management
location ~ ^/entity/(.*) {
proxy_set_header Host {{env "ENTITY_MANAGEMENT_HOST"}};
proxy_pass http://entity_management/entity/$1$is_args$args;
proxy_pass https://entity_management/entity/$1$is_args$args;
}

# Manifest API
location ~ ^/presentation/(.*)/manifest$ {
proxy_set_header Host {{env "MANIFEST_API_HOST"}};
proxy_pass http://manifest_api/presentation/$1/manifest$is_args$args;
proxy_pass https://manifest_api/presentation/$1/manifest$is_args$args;
}

# Fulltext API
location ~ ^/(fulltext|presentation)/(.*) {
proxy_set_header Host {{env "FULLTEXT_API_HOST"}};
proxy_pass http://fulltext_api/presentation/$2$is_args$args;
proxy_pass https://fulltext_api/presentation/$2$is_args$args;
}

# Recommendation API
location ~ ^/recommend/(.*) {
proxy_set_header Host {{env "RECOMMENDATION_API_HOST"}};
proxy_pass http://recommendation_api/recommend/$1$is_args$args;
proxy_pass https://recommendation_api/recommend/$1$is_args$args;
}

# Recommendation API (alternative path)
location ~ ^/set/(.*)/recommend {
proxy_set_header Host {{env "RECOMMENDATION_API_HOST"}};
proxy_pass http://recommendation_api/recommend/set/$1$is_args$args;
proxy_pass https://recommendation_api/recommend/set/$1$is_args$args;
}

# Sets API
location ~ ^/set/(.*) {
proxy_set_header Host {{env "SET_API_HOST"}};
proxy_pass http://set_api/set/$1$is_args$args;
proxy_pass https://set_api/set/$1$is_args$args;
}

# ----------------------------------------------------------
Expand Down

0 comments on commit 01cf42b

Please sign in to comment.