user nginx; worker_processes 1; events { worker_connections 512; } http { include mime.types; server_tokens off; gzip on; gzip_proxied any; gzip_http_version 1.1; gzip_comp_level 6; gzip_types text/plain text/css text/javascript application/json application/x-javascript text/xml application/xml application/xml+rss; gzip_disable msie6; 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 $http_upgrade $proxy_connection { default upgrade; "" close; } upstream exo_app { server exo:8080; } server { listen 80 default_server; #server_name my.server.name; # Pass the client informations the the backend proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; client_max_body_size 0; location ~ ((/websocket)|(\/[\d]+\.[\d]+\.[\d]+[\.|-][\d]+(.+)\/websocket)|^(\/[\d]+\.[\d]+\.[\d]+[\.|-].+)?(\/doc\/.*)) { proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $http_host; proxy_set_header X-Forwarded-Host $the_host; proxy_set_header X-Forwarded-Proto $the_scheme; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_http_version 1.1; proxy_pass http://onlyoffice$1$2$is_args$args; } location ~ ^(\/[\d]+\.[\d]+\.[\d]+[\.|-].+)/ { proxy_pass http://onlyoffice; } location ~ ^/OfficeWeb { proxy_pass http://onlyoffice; } location ~ ^/downloadfile { proxy_pass http://onlyoffice; } location ~ ^/converter { proxy_pass http://onlyoffice; } location ~ ^/printfile { proxy_pass http://onlyoffice; } location ~ ^/cache { proxy_pass http://onlyoffice; } location ~ ^/web-apps { proxy_pass http://onlyoffice; } location ~ ^/coauthoring { add_header X-Frame-Options SAMEORIGIN always; proxy_pass http://onlyoffice; } # Websocket for live edition location ~ /websocket$ { proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_pass http://onlyoffice; } location / { proxy_pass http://exo_app; } # Websocket for Cometd location /cometd/cometd { proxy_pass http://exo:8080; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } } }