-
Notifications
You must be signed in to change notification settings - Fork 356
Added nginx #3
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: DevOps
Are you sure you want to change the base?
Added nginx #3
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 | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -38,6 +38,20 @@ services: | |||||||||||||||
| timeout: 5s | ||||||||||||||||
| retries: 5 | ||||||||||||||||
| start_period: 30s | ||||||||||||||||
|
|
||||||||||||||||
| nginx: | ||||||||||||||||
| build: ./nginx | ||||||||||||||||
| container_name: nginx | ||||||||||||||||
| ports: | ||||||||||||||||
| - "80:80" | ||||||||||||||||
| restart: always | ||||||||||||||||
| depends_on: | ||||||||||||||||
| - mainapp | ||||||||||||||||
|
Comment on lines
+46
to
+48
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. 🛠️ Refactor suggestion Fix formatting issues and enhance dependency configuration The current configuration has formatting issues and could benefit from enhanced dependency management. Apply this diff to fix both: restart: always
- depends_on:
- - mainapp
+ depends_on:
+ mainapp:
+ condition: service_healthy📝 Committable suggestion
Suggested change
🧰 Tools🪛 yamllint[error] 47-47: trailing spaces (trailing-spaces) [warning] 48-48: wrong indentation: expected 6 but found 7 (indentation) [error] 48-48: trailing spaces (trailing-spaces) |
||||||||||||||||
| healthcheck: | ||||||||||||||||
| test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:80"] | ||||||||||||||||
| interval: 30s | ||||||||||||||||
| timeout: 10s | ||||||||||||||||
| retries: 10 | ||||||||||||||||
| networks: | ||||||||||||||||
| - bankapp | ||||||||||||||||
| networks: | ||||||||||||||||
| bankapp: | ||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| FROM nginx:1.23.3-alpine | ||
|
|
||
| COPY ./nginx.conf /etc/nginx/nginx.conf |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,60 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| worker_processes auto; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pid /var/run/nginx.pid; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| events { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| worker_connections 1024; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| http { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sendfile on; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tcp_nopush on; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tcp_nodelay on; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| keepalive_timeout 65; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| types_hash_max_size 2048; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+8
to
+17
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. 🛠️ Refactor suggestion Optimize rate limiting and enable compression. The current rate limiting of 1 request per second might be too restrictive for production use. Also, enabling gzip compression could significantly improve performance. http {
- limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;
+ limit_req_zone $binary_remote_addr zone=one:10m rate=10r/s;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
+
+ # Enable compression
+ gzip on;
+ gzip_vary on;
+ gzip_proxied any;
+ gzip_comp_level 6;
+ gzip_types text/plain text/css text/xml application/json application/javascript application/xml+rss application/atom+xml image/svg+xml;📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| add_header X-Frame-Options "SAMEORIGIN"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| add_header X-XSS-Protection "1; mode=block"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| add_header X-Content-Type-Options "nosniff"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+20
to
+22
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. 🛠️ Refactor suggestion Enhance security with additional headers. Consider adding more security headers to improve the application's security posture. add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
+ add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
+ add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline';" always;
+ add_header Referrer-Policy "strict-origin-when-cross-origin" always;📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| include /etc/nginx/mime.types; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| default_type application/octet-stream; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| access_log /var/log/nginx/access.log; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| error_log /var/log/nginx/error.log; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| server { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| listen 80; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| server_name localhost; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| location / { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| limit_req zone=one burst=5; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| proxy_pass http://mainapp:8080; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| proxy_connect_timeout 60s; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| proxy_send_timeout 60s; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| proxy_read_timeout 60s; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| proxy_buffering on; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| proxy_buffer_size 4k; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| proxy_buffers 4 32k; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| proxy_busy_buffers_size 64k; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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.
💡 Codebase verification
Security measures needed for nginx reverse proxy
Based on the nginx configuration review:
Recommended changes:
🔗 Analysis chain
Consider security implications of exposing port 80
Since you're exposing HTTP port directly to the host:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 161
Script:
Length of output: 2818