Skip to content

Commit

Permalink
Fixed nginx rule bug
Browse files Browse the repository at this point in the history
  • Loading branch information
mandatoryprogrammer committed May 30, 2016
1 parent e8de55c commit e3df58c
Showing 1 changed file with 33 additions and 22 deletions.
55 changes: 33 additions & 22 deletions generate_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@
rewrite ^/(.*)$ https://www.fakedomain.com/$1 permanent;
}
}
server {
# Redirect payloads to HTTPS
listen 80;
server_name *.fakedomain.com;
proxy_set_header X-Forwarded-For $remote_addr;
return 307 https://$host$request_uri;
client_max_body_size 500M; # In case we have an extra large payload capture
}
server {
# Redirect HTTPS to www
listen 443;
Expand All @@ -26,7 +37,27 @@
}
server {
# Redirect to HTTPS
# API proxy
listen 443;
ssl on;
ssl_certificate /etc/nginx/ssl/fakedomain.com.crt; # Wildcard SSL certificate
ssl_certificate_key /etc/nginx/ssl/fakedomain.com.key; # Wildcard SSL certificate key
server_name *.fakedomain.com;
access_log /var/log/nginx/fakedomain.com.vhost.access.log;
error_log /var/log/nginx/fakedomain.com.vhost.error.log;
client_max_body_size 500M;
location / {
proxy_pass http://localhost:8888;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
}
}
server {
# Redirect api to HTTPS
listen 80;
server_name api.fakedomain.com; # Subdomain for API server
proxy_set_header X-Forwarded-For $remote_addr;
Expand All @@ -36,7 +67,7 @@
}
server {
# Redirect to HTTPS
# Redirect www to HTTPS
listen 80;
server_name www.fakedomain.com;
location / {
Expand All @@ -59,26 +90,6 @@
proxy_set_header Host $host;
}
}
server {
# API proxy
listen 443;
ssl on;
ssl_certificate /etc/nginx/ssl/fakedomain.com.crt; # Wildcard SSL certificate
ssl_certificate_key /etc/nginx/ssl/fakedomain.com.key; # Wildcard SSL certificate key
server_name *.fakedomain.com;
access_log /var/log/nginx/fakedomain.com.vhost.access.log;
error_log /var/log/nginx/fakedomain.com.vhost.error.log;
client_max_body_size 500M;
location / {
proxy_pass http://localhost:8888;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
}
}
"""

settings = {
Expand Down

0 comments on commit e3df58c

Please sign in to comment.