Skip to content

Commit

Permalink
reverse-proxy-for-free-basics (#62): created rp4fb-subdomain.conf
Browse files Browse the repository at this point in the history
  • Loading branch information
fititnt committed Jun 8, 2019
1 parent d4a1b43 commit 01bd20e
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 8 deletions.
3 changes: 2 additions & 1 deletion docker/reverse-proxy-for-free-basics/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ FROM pagespeed/nginx-pagespeed
COPY ./etc/nginx/nginx.conf /etc/nginx/nginx.conf
#COPY ./etc/nginx/sites-available/nginx.vh.default.conf /etc/nginx/sites-available/default
#COPY ./etc/nginx/sites-available/etica.ai.conf /etc/nginx/sites-available/default
COPY ./etc/nginx/sites-available/inclusao.etica.ai.conf /etc/nginx/conf.d/inclusao.etica.ai.conf
COPY ./etc/nginx/sites-available/inclusao.etica.ai.conf /etc/nginx/conf.d/inclusao.etica.ai.conf
COPY ./etc/nginx/sites-available/rp4fb-subdomain.conf /etc/nginx/conf.d/rp4fb-subdomain.conf
2 changes: 1 addition & 1 deletion docker/reverse-proxy-for-free-basics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ content to [Free Basics by Facebook](https://info.internet.org).

# Apache/incubator-pagespeed-ngx
- <https://github.com/apache/incubator-pagespeed-ngx/tree/master/docker>
- <https://www.modpagespeed.com/doc/configuration#virtual-hosts>
- <https://www.modpagespeed.com/doc/configuration#virtual-hosts>
13 changes: 13 additions & 0 deletions docker/reverse-proxy-for-free-basics/etc/nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,19 @@ http {

#gzip on;


# NOTE If you use rp4fb-subdomain.conf and need resolve hostnames instead of
# a hardcoded reverse proxy IP, maybe you will need the line
# resolver 127.0.0.11 ipv6=off;
#
# @see https://stackoverflow.com/questions/35744650/docker-network-nginx-resolver/37656784#37656784
resolver 127.0.0.11 ipv6=off;

pagespeed on;

# Needs to exist and be writable by nginx. Use tmpfs for best performance.
pagespeed FileCachePath /var/cache/ngx_pagespeed;

# Is possible to overide these defaults on your virtual hosts
# @see https://www.modpagespeed.com/doc/configuration#virtual-hosts
# pagespeed DisableFilters canonicalize_javascript_libraries, combine_javascript, defer_javascript, inline_javascript, insert_ga, lazyload_images, outline_javascript, rewrite_javascript;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
server {
listen 80;
server_name rp4fb.*;
server_name rp4fb.inclusao.etica.ai;

location / {
access_log off;
Expand All @@ -13,11 +13,6 @@ server {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

pagespeed on;

# Needs to exist and be writable by nginx. Use tmpfs for best performance.
pagespeed FileCachePath /var/cache/ngx_pagespeed;

# Ensure requests for pagespeed optimized resources go to the pagespeed handler
# and no extraneous headers get set.
location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
server {
listen 80;
#server_name rp4fb.*;
server_name ~^(rp4fb\.)?(?<mydomain>.+)$;

location / {
access_log off;
proxy_pass http://$mydomain:80;
#proxy_pass http://inclusao.etica.ai:80;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $mydomain;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

# Ensure requests for pagespeed optimized resources go to the pagespeed handler
# and no extraneous headers get set.
location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" {
add_header "" "";
}
location ~ "^/pagespeed_static/" { }
location ~ "^/ngx_pagespeed_beacon$" { }

}

0 comments on commit 01bd20e

Please sign in to comment.