-
Notifications
You must be signed in to change notification settings - Fork 71
Task 5 #99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Task 5 #99
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
2.6.1 | ||
2.6.3 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Case-study оптимизации | ||
|
||
## 1. Настроить сертификат для локального HTTPS | ||
|
||
## 2. Настраиваем NGinx как reverse-proxy | ||
|
||
## 3. Настроить HTTP/2 и server-push | ||
|
||
Поднял dev.to локально. | ||
С помощью 'mkcert' создал сертификаты. | ||
Установил и сконфигурировал `NGinx` как reverse-proxy. | ||
Поднял `https://localhost` | ||
Дополнил конфиг `NGinx` поддержкой `HTTP/2` и `server-push`. Итоговый конфиг - /opt/homebrew/etc/nginx/servers/devto.conf | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
|
||
```bash | ||
server { | ||
listen 443 http2 ssl; | ||
server_name localhost; | ||
|
||
ssl_certificate /opt/homebrew/etc/nginx/certs/localhost.pem; | ||
ssl_certificate_key /opt/homebrew/etc/nginx/certs/localhost-key.pem; | ||
|
||
ssl_session_cache shared:SSL:1m; | ||
ssl_session_timeout 5m; | ||
|
||
ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:DES-CBC3-SHA:!RC4:!aNULL:!eNULL:!MD5:!EXPORT:!EXP:!LOW:!SEED:!CAMELLIA:!IDEA:!PSK:!SRP:!SSLv:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA'; | ||
ssl_prefer_server_ciphers on; | ||
|
||
location / { | ||
http2_push_preload on; | ||
proxy_set_header Host $host; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header X-Forwarded-Proto https; | ||
proxy_redirect off; | ||
proxy_pass http://127.0.0.1:3000; | ||
} | ||
} | ||
``` | ||
|
||
Убедился, что ресурсы получаются по протоколу http/2 | ||
|
||
## 4. Поэксперементировать с HTTP/2 server-push | ||
|
||
Настроил server-push. Проверил утилитой http2-push-detect: | ||
|
||
``` | ||
+ [email protected] | ||
added 2 packages from 9 contributors in 0.782s | ||
❯ http2-push-detect 'https://localhost' | ||
Receiving pushed resource: /assets/bell.svg | ||
Receiving pushed resource: /assets/menu.svg | ||
Receiving pushed resource: /assets/connect.svg | ||
Receiving pushed resource: /assets/stack.svg | ||
Receiving pushed resource: /assets/lightning.svg | ||
``` | ||
|
||
Подготовил har-отчеты (также приложил скрины) | ||
|
||
С помощью https://host.docker.internal подключил nginx через docker, удобно, и логи сразу видны (полезно на будущее) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,10 @@ | ||
version: "3" | ||
services: | ||
web: &rails_base | ||
build: | ||
dockerfile: Dockerfile | ||
context: . | ||
ports: | ||
- "3000:3000" | ||
depends_on: | ||
- db | ||
environment: | ||
RAILS_ENV: development | ||
DATABASE_URL: postgres://postgres:mysecretpassword@db:5432/postgres | ||
YARN_INTEGRITY_ENABLED: "false" | ||
nginx: | ||
image: nginx:latest | ||
container_name: webserver | ||
volumes: | ||
- .:/usr/src/app | ||
command: bundle exec rails server -b 0.0.0.0 -p 3000 | ||
jobs: | ||
ports: [] | ||
<<: *rails_base | ||
command: rails jobs:work | ||
webpacker: | ||
ports: [] | ||
<<: *rails_base | ||
command: ./bin/webpack-dev-server | ||
db: | ||
image: postgres | ||
- ./nginx/nginx.conf:/etc/nginx/nginx.conf | ||
- ./nginx/certs:/etc/nginx/certs | ||
ports: | ||
- "5432:5432" | ||
- 443:443 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
events {} | ||
|
||
http { | ||
server { | ||
listen 443 http2 ssl; | ||
server_name localhost; | ||
|
||
ssl_certificate /etc/nginx/certs/localhost.pem; | ||
ssl_certificate_key /etc/nginx/certs/localhost-key.pem; | ||
ssl_session_timeout 5m; | ||
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; | ||
ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:DES-CBC3-SHA:!RC4:!aNULL:!eNULL:!MD5:!EXPORT:!EXP:!LOW:!SEED:!CAMELLIA:!IDEA:!PSK:!SRP:!SSLv:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA'; | ||
ssl_prefer_server_ciphers on; | ||
|
||
# https://docs.docker.com/desktop/networking/ | ||
location / { | ||
http2_push_preload on; | ||
proxy_set_header Host $host; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header X-Forwarded-Proto https; | ||
proxy_redirect off; | ||
proxy_pass http://host.docker.internal:3000; | ||
} | ||
} | ||
} |
Large diffs are not rendered by default.
Large diffs are not rendered by default.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Видно, что картинки первыми начинают лететь ✅ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, I've fixed it by now