map $http_host $this_host { "" $host; default $http_host; } map $http_x_forwarded_proto $the_scheme { default $http_x_forwarded_proto; "" $scheme; } map $http_x_forwarded_host $the_host { default $http_x_forwarded_host; "" $this_host; } map $uri $basename { ~/(?[^/]*)$ $captured_basename; } map $request_uri $header_x_frame_options { ~*^/(favicon\.ico|products\/files\/share|products\/files\/saveas|products\/files\/filechoice|products\/files\/doceditor|thirdparty\/plugin) ""; default "SAMEORIGIN"; } include /etc/nginx/includes/onlyoffice-*.conf; server { listen 8092; add_header Access-Control-Allow-Origin *; add_header X-Frame-Options $header_x_frame_options; large_client_header_buffers 4 16k; set $X_REWRITER_URL $the_scheme://$the_host; if ($http_x_rewriter_url != '') { set $X_REWRITER_URL $http_x_rewriter_url ; } gzip on; gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript; fastcgi_read_timeout 600; fastcgi_send_timeout 600; fastcgi_keep_conn on; fastcgi_intercept_errors on; include fastcgi_params; fastcgi_param HTTP_X_REWRITER_URL $http_x_rewriter_url; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO ""; location ~* ^/ds-vpath/ { rewrite /ds-vpath/(.*) /$1 break; proxy_pass http://172.18.0.4:80; proxy_redirect off; client_max_body_size 100m; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $http_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-Host $the_host/ds-vpath; proxy_set_header X-Forwarded-Proto $the_scheme; } location / { proxy_pass http://localhost:5001; location ~* /(manifest.json|service-worker.js|appIcon.png|bg-error.png) { root $public_root; try_files /$basename /index.html =404; } } location /sockjs-node { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header Host $host; proxy_pass http://localhost:5001; proxy_redirect off; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } location /api/2.0 { location ~* /(files|encryption|privacyroom) { proxy_pass http://localhost:5007; proxy_set_header X-REWRITER-URL $X_REWRITER_URL; } location ~* /(authentication|modules|portal|security|settings|smtpsettings|capabilities|thirdparty) { proxy_pass http://localhost:5000; proxy_set_header X-REWRITER-URL $X_REWRITER_URL; location ~* portal/(.*)(backup|restore)(.*) { rewrite (.*)/portal/(.*) $1/backup/$2 break; proxy_redirect off; proxy_pass http://localhost:5012; proxy_set_header X-REWRITER-URL $X_REWRITER_URL; } } location ~* /(people|group) { proxy_pass http://localhost:5004; proxy_set_header X-REWRITER-URL $X_REWRITER_URL; } location ~* /backup { proxy_pass http://localhost:5012; proxy_set_header X-REWRITER-URL $X_REWRITER_URL; } } location /storage { proxy_pass http://localhost:5003; proxy_set_header X-REWRITER-URL $X_REWRITER_URL; } location /login.ashx { proxy_pass http://localhost:5003; proxy_set_header X-REWRITER-URL $X_REWRITER_URL; } location /products { location ~* /people { #rewrite products/people/(.*) /$1 break; proxy_pass http://localhost:5002; proxy_set_header X-REWRITER-URL $X_REWRITER_URL; location ~* /(sockjs-node|locales) { rewrite products/people(.*)/(sockjs-node|locales)/(.*) /$2/$3 break; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header Host $host; proxy_pass http://localhost:5002; proxy_redirect off; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } location ~* /(manifest.json|service-worker.js|appIcon.png|bg-error.png) { root $public_root; try_files /$basename /index.html =404; } } location ~* /files { #rewrite products/files/(.*) /$1 break; proxy_pass http://localhost:5008; proxy_set_header X-REWRITER-URL $X_REWRITER_URL; location ~* /(sockjs-node|locales) { rewrite products/files(.*)/(sockjs-node|locales)/(.*) /$2/$3 break; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header Host $host; proxy_pass http://localhost:5008; proxy_redirect off; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } location ~* /(manifest.json|service-worker.js|appIcon.png|bg-error.png) { root $public_root; try_files /$basename /index.html =404; } location ~* (/httphandlers/filehandler.ashx|ChunkedUploader.ashx) { proxy_pass http://localhost:5007; proxy_set_header X-REWRITER-URL $X_REWRITER_URL; } } location ~* (/crm|/mail/|/calendar|/projects|/talk) { #rewrite products/people/(.*) /$1 break; proxy_pass http://localhost:5001; proxy_set_header X-REWRITER-URL $X_REWRITER_URL; location ~* /(sockjs-node|locales) { rewrite products/people(.*)/(sockjs-node|locales)/(.*) /$2/$3 break; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header Host $host; proxy_pass http://localhost:5001; proxy_redirect off; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } location ~* /(manifest.json|service-worker.js|appIcon.png|bg-error.png) { root $public_root; try_files /$basename /index.html =404; } } } location /apisystem { rewrite apisystem/(.*) /$1 break; proxy_pass http://localhost:5010; proxy_set_header X-REWRITER-URL $X_REWRITER_URL; } location /sh { rewrite sh/(.*) /$1 break; proxy_pass http://localhost:9999; proxy_set_header X-REWRITER-URL $X_REWRITER_URL; } }