Skip to content

Commit 8f1fa2e

Browse files
committed
Simplify Nginx configuration
1 parent fdb0110 commit 8f1fa2e

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

.ebextensions/01_nginx.config

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
files:
2+
"/etc/nginx/conf.d/proxy.conf":
3+
mode: "000644"
4+
owner: root
5+
group: root
6+
content: |
7+
server {
8+
listen 80;
9+
server_name localhost;
10+
11+
location / {
12+
proxy_pass http://127.0.0.1:5000;
13+
proxy_set_header Host $host;
14+
proxy_set_header X-Real-IP $remote_addr;
15+
16+
# CORS configuration
17+
if ($request_method = 'OPTIONS') {
18+
add_header 'Access-Control-Allow-Origin' '*';
19+
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
20+
add_header 'Access-Control-Allow-Headers' '*';
21+
add_header 'Access-Control-Max-Age' 1728000;
22+
add_header 'Content-Type' 'text/plain charset=UTF-8';
23+
add_header 'Content-Length' 0;
24+
return 204;
25+
}
26+
add_header 'Access-Control-Allow-Origin' '*' always;
27+
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
28+
add_header 'Access-Control-Allow-Headers' '*' always;
29+
}
30+
}
31+
32+
container_commands:
33+
01_reload_nginx:
34+
command: "service nginx reload"

0 commit comments

Comments
 (0)