DocSpace-buildtools/config/nginx/onlyoffice.conf
2021-10-15 12:52:13 +03:00

433 lines
12 KiB
Plaintext

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>[^/]*)$ $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";
}
map $request_uri $cache_control {
default "no-cache, no-store, must-revalidate";
~*\/(api\/2\.0.*|storage|login\.ashx|products\/.+\/httphandlers\/filehandler\.ashx|ChunkedUploader.ashx|apisystem|sh|remoteEntry\.js) "no-cache, no-store, must-revalidate";
~*\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf|md|css|js)$ "public, no-transform";
}
include /etc/nginx/includes/onlyoffice-*.conf;
server {
listen 8092;
add_header Access-Control-Allow-Origin *;
add_header X-Frame-Options $header_x_frame_options;
add_header Cache-Control $cache_control;
etag on;
large_client_header_buffers 4 16k;
client_max_body_size 4G;
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|sw.js|appIcon.png|bg-error.png|favicon.ico|debuginfo.md) {
root $public_root;
try_files /$basename /index.html =404;
}
location ~* /static/images/icons/(?<content>[^/]+) {
root $public_root;
try_files /images/icons/$content/$basename /index.html =404;
}
location ~* /static/images/ {
root $public_root;
try_files /images/$basename /index.html =404;
}
location ~* /static/fonts/ {
expires 365d;
root $public_root;
try_files /fonts/$basename /index.html =404;
}
location ~* /static/offline/ {
root $public_root;
try_files /offline/$basename /index.html =404;
}
location ~* /thirdparty/ {
root $public_root;
try_files /thirdparty/third-party.html /index.html =404;
}
location ~* /static/locales/(?<content>[^/]+) {
root $public_root;
try_files /locales/$content/$basename /index.html =404;
}
location ~* /static/scripts/ {
root $public_root;
try_files /scripts/$basename /index.html =404;
}
}
location /login {
#rewrite login/(.*) /$1 break;
proxy_pass http://localhost:5011;
}
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 ~* /(people|group) {
proxy_pass http://localhost:5004;
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 ~* /backup {
proxy_pass http://localhost:5012;
proxy_set_header X-REWRITER-URL $X_REWRITER_URL;
}
location ~* /project {
proxy_pass http://localhost:5020;
proxy_set_header X-REWRITER-URL $X_REWRITER_URL;
}
location ~* /crm {
proxy_pass http://localhost:5021;
proxy_set_header X-REWRITER-URL $X_REWRITER_URL;
}
location ~* /mail {
proxy_pass http://localhost:5022;
proxy_set_header X-REWRITER-URL $X_REWRITER_URL;
}
location ~* /calendar {
proxy_pass http://localhost:5023;
proxy_set_header X-REWRITER-URL $X_REWRITER_URL;
}
}
location /storage {
add_header Cache-Control $cache_control;
proxy_pass http://localhost:5003;
proxy_set_header X-REWRITER-URL $X_REWRITER_URL;
}
location /login.ashx {
add_header Cache-Control $cache_control;
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) {
rewrite products/people(.*)/(sockjs-node)/(.*) /$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/doceditor {
#rewrite products/files/doceditor/(.*) /$1 break;
proxy_pass http://localhost:5013;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
location ~* /files {
#rewrite products/files/(.*) /$1 break;
proxy_pass http://localhost:5008;
proxy_set_header X-REWRITER-URL $X_REWRITER_URL;
location ~* /sockjs-node {
rewrite products/files(.*)/sockjs-node/(.*) /$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) {
add_header Cache-Control $cache_control;
proxy_pass http://localhost:5007;
proxy_set_header X-REWRITER-URL $X_REWRITER_URL;
}
}
location ~* /crm {
#rewrite products/crm/(.*) /$1 break;
proxy_pass http://localhost:5014;
proxy_set_header X-REWRITER-URL $X_REWRITER_URL;
location ~* /sockjs-node {
rewrite products/crm(.*)/sockjs-node/(.*) /$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:5014;
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) {
add_header Cache-Control $cache_control;
proxy_pass http://localhost:5007;
proxy_set_header X-REWRITER-URL $X_REWRITER_URL;
}
}
location ~* /projects {
#rewrite products/projects/(.*) /$1 break;
proxy_pass http://localhost:5015;
proxy_set_header X-REWRITER-URL $X_REWRITER_URL;
location ~* /sockjs-node {
rewrite products/projects(.*)/sockjs-node/(.*) /$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:5015;
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) {
add_header Cache-Control $cache_control;
proxy_pass http://localhost:5007;
proxy_set_header X-REWRITER-URL $X_REWRITER_URL;
}
}
location ~* /mail {
#rewrite products/mail/(.*) /$1 break;
proxy_pass http://localhost:5016;
proxy_set_header X-REWRITER-URL $X_REWRITER_URL;
location ~* /sockjs-node {
rewrite products/projects(.*)/sockjs-node/(.*) /$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:5016;
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) {
add_header Cache-Control $cache_control;
proxy_pass http://localhost:5007;
proxy_set_header X-REWRITER-URL $X_REWRITER_URL;
}
}
location ~* /calendar {
#rewrite products/calendar/(.*) /$1 break;
proxy_pass http://localhost:5017;
proxy_set_header X-REWRITER-URL $X_REWRITER_URL;
location ~* /sockjs-node {
rewrite products/projects(.*)/sockjs-node/(.*) /$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:5017;
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) {
add_header Cache-Control $cache_control;
proxy_pass http://localhost:5007;
proxy_set_header X-REWRITER-URL $X_REWRITER_URL;
}
}
}
location /apisystem {
add_header Cache-Control $cache_control;
rewrite apisystem/(.*) /$1 break;
proxy_pass http://localhost:5010;
proxy_set_header X-REWRITER-URL $X_REWRITER_URL;
}
location /sh {
add_header Cache-Control $cache_control;
rewrite sh/(.*) /$1 break;
proxy_pass http://localhost:9999;
proxy_set_header X-REWRITER-URL $X_REWRITER_URL;
}
location /caldav {
rewrite caldav/(.*) /$1 break;
proxy_pass http://localhost:5232;
proxy_set_header X-REWRITER-URL $X_REWRITER_URL;
}
}