diff --git a/Dockerfile b/Dockerfile index 47a354c..a1bf1b1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 \ No newline at end of file +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 \ No newline at end of file diff --git a/README.md b/README.md index 5a7476a..de663d4 100644 --- a/README.md +++ b/README.md @@ -7,4 +7,4 @@ content to [Free Basics by Facebook](https://info.internet.org). # Apache/incubator-pagespeed-ngx - -- \ No newline at end of file +- diff --git a/etc/nginx/nginx.conf b/etc/nginx/nginx.conf index 5f1e4a5..010efb2 100644 --- a/etc/nginx/nginx.conf +++ b/etc/nginx/nginx.conf @@ -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; diff --git a/etc/nginx/sites-available/inclusao.etica.ai.conf b/etc/nginx/sites-available/inclusao.etica.ai.conf index 98aef67..433b882 100644 --- a/etc/nginx/sites-available/inclusao.etica.ai.conf +++ b/etc/nginx/sites-available/inclusao.etica.ai.conf @@ -1,6 +1,6 @@ server { listen 80; - server_name rp4fb.*; + server_name rp4fb.inclusao.etica.ai; location / { access_log off; @@ -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}\.[^.]+" { diff --git a/etc/nginx/sites-available/rp4fb-subdomain.conf b/etc/nginx/sites-available/rp4fb-subdomain.conf new file mode 100644 index 0000000..a9cf98e --- /dev/null +++ b/etc/nginx/sites-available/rp4fb-subdomain.conf @@ -0,0 +1,23 @@ +server { + listen 80; + #server_name rp4fb.*; + server_name ~^(rp4fb\.)?(?.+)$; + + 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$" { } + +} \ No newline at end of file