From c32b052e233eed88abc17b81ebf53ff331f03dcf Mon Sep 17 00:00:00 2001 From: CO0LGIRL Date: Wed, 18 Mar 2026 01:31:23 +0300 Subject: [PATCH 1/6] build: add submodule for external-repo --- .gitmodules | 3 +++ frontend | 1 + 2 files changed, 4 insertions(+) create mode 100644 .gitmodules create mode 160000 frontend diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..3711333 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "frontend"] + path = frontend + url = git@github.com:Codzilla-HSE/frontend.git diff --git a/frontend b/frontend new file mode 160000 index 0000000..8799bc3 --- /dev/null +++ b/frontend @@ -0,0 +1 @@ +Subproject commit 8799bc3910b7690326c899319a6af34ee2b9e8f2 From f8b92cfd32c1ec2e95c98664e4dd71c609b948fb Mon Sep 17 00:00:00 2001 From: CO0LGIRL Date: Wed, 18 Mar 2026 02:49:49 +0300 Subject: [PATCH 2/6] feat: setup nginx proxy config --- .gitignore | 3 ++ infra/nginx/logs/.gitkeep | 0 infra/nginx/mime.types | 99 +++++++++++++++++++++++++++++++++++++++ infra/nginx/nginx.conf | 56 ++++++++++++++++++++++ 4 files changed, 158 insertions(+) create mode 100644 .gitignore create mode 100644 infra/nginx/logs/.gitkeep create mode 100644 infra/nginx/mime.types create mode 100644 infra/nginx/nginx.conf diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8506864 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +# .gitignore +infra/nginx/logs/*.log +infra/nginx/logs/*.pid \ No newline at end of file diff --git a/infra/nginx/logs/.gitkeep b/infra/nginx/logs/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/infra/nginx/mime.types b/infra/nginx/mime.types new file mode 100644 index 0000000..1c00d70 --- /dev/null +++ b/infra/nginx/mime.types @@ -0,0 +1,99 @@ + +types { + text/html html htm shtml; + text/css css; + text/xml xml; + image/gif gif; + image/jpeg jpeg jpg; + application/javascript js; + application/atom+xml atom; + application/rss+xml rss; + + text/mathml mml; + text/plain txt; + text/vnd.sun.j2me.app-descriptor jad; + text/vnd.wap.wml wml; + text/x-component htc; + + image/avif avif; + image/png png; + image/svg+xml svg svgz; + image/tiff tif tiff; + image/vnd.wap.wbmp wbmp; + image/webp webp; + image/x-icon ico; + image/x-jng jng; + image/x-ms-bmp bmp; + + font/woff woff; + font/woff2 woff2; + + application/java-archive jar war ear; + application/json json; + application/mac-binhex40 hqx; + application/msword doc; + application/pdf pdf; + application/postscript ps eps ai; + application/rtf rtf; + application/vnd.apple.mpegurl m3u8; + application/vnd.google-earth.kml+xml kml; + application/vnd.google-earth.kmz kmz; + application/vnd.ms-excel xls; + application/vnd.ms-fontobject eot; + application/vnd.ms-powerpoint ppt; + application/vnd.oasis.opendocument.graphics odg; + application/vnd.oasis.opendocument.presentation odp; + application/vnd.oasis.opendocument.spreadsheet ods; + application/vnd.oasis.opendocument.text odt; + application/vnd.openxmlformats-officedocument.presentationml.presentation + pptx; + application/vnd.openxmlformats-officedocument.spreadsheetml.sheet + xlsx; + application/vnd.openxmlformats-officedocument.wordprocessingml.document + docx; + application/vnd.wap.wmlc wmlc; + application/wasm wasm; + application/x-7z-compressed 7z; + application/x-cocoa cco; + application/x-java-archive-diff jardiff; + application/x-java-jnlp-file jnlp; + application/x-makeself run; + application/x-perl pl pm; + application/x-pilot prc pdb; + application/x-rar-compressed rar; + application/x-redhat-package-manager rpm; + application/x-sea sea; + application/x-shockwave-flash swf; + application/x-stuffit sit; + application/x-tcl tcl tk; + application/x-x509-ca-cert der pem crt; + application/x-xpinstall xpi; + application/xhtml+xml xhtml; + application/xspf+xml xspf; + application/zip zip; + + application/octet-stream bin exe dll; + application/octet-stream deb; + application/octet-stream dmg; + application/octet-stream iso img; + application/octet-stream msi msp msm; + + audio/midi mid midi kar; + audio/mpeg mp3; + audio/ogg ogg; + audio/x-m4a m4a; + audio/x-realaudio ra; + + video/3gpp 3gpp 3gp; + video/mp2t ts; + video/mp4 mp4; + video/mpeg mpeg mpg; + video/quicktime mov; + video/webm webm; + video/x-flv flv; + video/x-m4v m4v; + video/x-mng mng; + video/x-ms-asf asx asf; + video/x-ms-wmv wmv; + video/x-msvideo avi; +} diff --git a/infra/nginx/nginx.conf b/infra/nginx/nginx.conf new file mode 100644 index 0000000..78e6e8b --- /dev/null +++ b/infra/nginx/nginx.conf @@ -0,0 +1,56 @@ +worker_processes 1; + +error_log logs/error.log notice; +pid logs/nginx.pid; + +events { + worker_connections 1024; +} + +http { + include mime.types; + default_type application/octet-stream; + + gzip on; + gzip_types text/plain text/css application/json application/javascript text/xml; + gzip_min_length 1000; + + client_max_body_size 10M; + + add_header X-Frame-Options "SAMEORIGIN"; + add_header X-Content-Type-Options "nosniff"; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log logs/access.log main; + sendfile on; + keepalive_timeout 65; + + + upstream backend_servers { + server 127.0.0.1:8080; + } + + server { + listen 80; + server_name localhost; + + root /usr/share/nginx/html; + index index.html; + + location / { + try_files $uri $uri/ /index.html; + } + + location /auth/ { + proxy_pass http://backend_servers; + + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + } +} \ No newline at end of file From 72d00ccc17b27cd8326b5c33122f6d188c1a7240 Mon Sep 17 00:00:00 2001 From: CO0LGIRL Date: Wed, 18 Mar 2026 03:25:47 +0300 Subject: [PATCH 3/6] feat: add linting ci --- .github/workflows/lint.yml | 24 ++++++++++++++++++++++++ infra/nginx/nginx.conf | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..4c8da88 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,24 @@ +name: Nginx CI + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + lint-nginx: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install Nginx + run: sudo apt-get update && sudo apt-get install -y nginx + + - name: Create logs directory + run: mkdir -p infra/nginx/logs + + - name: Test Nginx configuration + run: sudo nginx -t -p infra/nginx/ -c nginx.conf \ No newline at end of file diff --git a/infra/nginx/nginx.conf b/infra/nginx/nginx.conf index 78e6e8b..311fa8e 100644 --- a/infra/nginx/nginx.conf +++ b/infra/nginx/nginx.conf @@ -37,7 +37,7 @@ http { listen 80; server_name localhost; - root /usr/share/nginx/html; + root /usr/share/nginx/html/dist; index index.html; location / { From 1035cbcc6c11bff736b591688296d2e25d78437b Mon Sep 17 00:00:00 2001 From: CO0LGIRL Date: Wed, 18 Mar 2026 03:33:12 +0300 Subject: [PATCH 4/6] docs: update README.md --- README.md | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index cf19fc2..6bcad7b 100644 --- a/README.md +++ b/README.md @@ -1 +1,32 @@ -# Application \ No newline at end of file +# nginx + +## Зависимости + +Для работы понадобится установленный `nginx`. +* **Ubuntu/Debian:** `sudo apt install nginx` +* **macOS:** `brew install nginx` + +> **Важно:** Убедитесь, что системный сервис nginx (если он запустился после установки) остановлен, чтобы он не занимал 80-й порт: +> `sudo lsof -i :80` (чтобы узнать занимает или нет) +> `sudo systemctl stop nginx` (Linux) или `brew services stop nginx` (macOS). + +## Как запустить локально + +1. Перейдите в папку с конфигурацией: + ```bash + cd infra/nginx +2. Запустите Nginx в привязанном к терминалу режиме (чтобы видеть ошибки и легко останавливать через Ctrl+C): + ```bash + sudo nginx -p . -c nginx.conf -g "daemon off;" + Сервер будет доступен по адресу http://localhost +3. Для проверки синтаксиса локально: + ```bash + sudo nginx -t -p . -c nginx.conf + Вы должны увидеть: + ```bash + nginx: the configuration file ./nginx.conf syntax is ok + nginx: configuration file ./nginx.conf test is successful + +4. Если вы запустили его в фоновом режиме (без daemon off;), остановить его можно командой из папки infra/nginx: + ```bash + sudo nginx -p . -c nginx.conf -s stop \ No newline at end of file From ce0a5c4abaf182aba319c67500ae1633db99c090 Mon Sep 17 00:00:00 2001 From: CO0LGIRL Date: Wed, 18 Mar 2026 03:34:47 +0300 Subject: [PATCH 5/6] docs: update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 6bcad7b..2ccdd15 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ 3. Для проверки синтаксиса локально: ```bash sudo nginx -t -p . -c nginx.conf + ``` Вы должны увидеть: ```bash nginx: the configuration file ./nginx.conf syntax is ok From f33fb9db6df1a5d6474a62f7feb8f48af7533b73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BD=D0=B8=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BB?= =?UTF-8?q?=D0=B0=D1=88=D0=BD=D0=B8=D0=BA=D0=BE=D0=B2?= Date: Wed, 18 Mar 2026 14:45:50 +0300 Subject: [PATCH 6/6] feat: add nginx proxy for backend routes --- .idea/workspace.xml | 105 +++++++++++++++++++++++++++++++++++++++++ infra/nginx/nginx.conf | 45 +++++++++++------- 2 files changed, 133 insertions(+), 17 deletions(-) create mode 100644 .idea/workspace.xml diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..5582b76 --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,105 @@ + + + + + + + + + + + + + + + { + "associatedIndex": 5 +} + + + + + + + + + + + + + + + + + + + + + + + + 1772824345782 + + + + + + + + + + + + \ No newline at end of file diff --git a/infra/nginx/nginx.conf b/infra/nginx/nginx.conf index 311fa8e..0b3cd60 100644 --- a/infra/nginx/nginx.conf +++ b/infra/nginx/nginx.conf @@ -1,7 +1,6 @@ worker_processes 1; - -error_log logs/error.log notice; -pid logs/nginx.pid; +error_log /var/log/nginx/error.log notice; +pid /var/run/nginx.pid; events { worker_connections 1024; @@ -10,34 +9,23 @@ events { http { include mime.types; default_type application/octet-stream; - gzip on; gzip_types text/plain text/css application/json application/javascript text/xml; gzip_min_length 1000; - client_max_body_size 10M; - add_header X-Frame-Options "SAMEORIGIN"; add_header X-Content-Type-Options "nosniff"; - - log_format main '$remote_addr - $remote_user [$time_local] "$request" ' - '$status $body_bytes_sent "$http_referer" ' - '"$http_user_agent" "$http_x_forwarded_for"'; - - access_log logs/access.log main; sendfile on; keepalive_timeout 65; - upstream backend_servers { - server 127.0.0.1:8080; + server backend:8080; } server { listen 80; server_name localhost; - - root /usr/share/nginx/html/dist; + root /usr/share/nginx/html; index index.html; location / { @@ -46,11 +34,34 @@ http { location /auth/ { proxy_pass http://backend_servers; - proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } + + location /problems/ { + proxy_pass http://backend_servers; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /submissions/ { + proxy_pass http://backend_servers; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /ws/ { + proxy_pass http://backend_servers; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_set_header Host $host; + } } } \ No newline at end of file