Skip to main content
Glama
add_attachments_nginx.shβ€’2.9 kB
#!/bin/bash # Script to add /attachments/ location to nginx trustypa.conf # Run this on the production server: bash scripts/add_attachments_nginx.sh set -e echo "πŸ“ Adding /attachments/ location to nginx trustypa.conf..." cd /opt/swissknife # Backup current config BACKUP_FILE="nginx/conf.d/trustypa.conf.backup-$(date +%Y%m%d-%H%M%S)" cp nginx/conf.d/trustypa.conf "$BACKUP_FILE" echo "βœ… Backup saved to $BACKUP_FILE" # Check if /attachments/ location already exists if grep -q "location /attachments/" nginx/conf.d/trustypa.conf; then echo "⚠️ /attachments/ location already exists in nginx config" echo " Skipping modification" exit 0 fi # Create temporary file with /attachments/ location block cat > /tmp/attachments_block.conf << 'EOF' # Attachments endpoint for Infocert signature (must be before /trustysign/ static files) location /attachments/ { proxy_pass http://iris-app:9000/attachments/; # Proxy headers 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; # Timeouts for large files proxy_connect_timeout 60s; proxy_send_timeout 120s; proxy_read_timeout 120s; # Buffering for downloads proxy_buffering on; proxy_buffer_size 128k; proxy_buffers 4 256k; proxy_busy_buffers_size 256k; } EOF # Insert /attachments/ block before /trustysign/ static files location # This ensures it's processed before the catch-all /trustysign/ block awk ' /# TrustySign Static Files \(PWA\)/ { # Found the TrustySign Static Files comment # Insert attachments block before it while ((getline line < "/tmp/attachments_block.conf") > 0) { print line } close("/tmp/attachments_block.conf") } { print } ' nginx/conf.d/trustypa.conf > /tmp/trustypa_with_attachments.conf # Replace original file mv /tmp/trustypa_with_attachments.conf nginx/conf.d/trustypa.conf echo "βœ… Location /attachments/ added to nginx config" # Test nginx configuration echo "πŸ” Testing nginx configuration..." docker exec swissknife-nginx nginx -t if [ $? -ne 0 ]; then echo "❌ Nginx configuration test failed!" echo " Restoring backup..." cp "$BACKUP_FILE" nginx/conf.d/trustypa.conf exit 1 fi echo "βœ… Nginx configuration valid" # Reload nginx echo "♻️ Reloading nginx..." docker exec swissknife-nginx nginx -s reload if [ $? -ne 0 ]; then echo "❌ Nginx reload failed!" exit 1 fi echo "βœ… Nginx reloaded successfully!" echo "" echo "πŸ§ͺ Test the endpoint:" echo " curl -I https://trustypa.brainaihub.tech/attachments/test.pdf" echo "" echo "πŸ“‹ View full config:" echo " cat /opt/swissknife/nginx/conf.d/trustypa.conf" # Cleanup rm -f /tmp/attachments_block.conf

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ilvolodel/iris-legacy'

If you have feedback or need assistance with the MCP directory API, please join our Discord server