Skip to content

Instantly share code, notes, and snippets.

@teisho
Forked from stbuehler/open-xchange-nginx.conf
Created July 14, 2020 07:53
Show Gist options
  • Save teisho/1450e39ac2ae6088bfde810085e2ac03 to your computer and use it in GitHub Desktop.
Save teisho/1450e39ac2ae6088bfde810085e2ac03 to your computer and use it in GitHub Desktop.
Open-Xchange nginx config
# route balancing only in commercial edition...
#map $cookie_JESSIONID $route_cookie1 {
# ~.+\.(?P<route>\w+)$ $route;
#}
#map $cookie_jsessionid $route_cookie2 {
# ~.+\.(?P<route>\w+)$ $route;
#}
#map $request_uri $route_uri1 {
# ~JSESSIONID=.+\.(?P<route>\w+)$ $route;
#}
#map $request_uri $route_uri2 {
# ~jsessionid=.+\.(?P<route>\w+)$ $route;
#}
upstream oxcluster {
server 127.0.0.1:8009 weight=50; # route=APP1;
# server oxhost2:8009 weight=50 route=APP2;
# sticky route $route_cookie1 $route_cookie2 $route_uri1 $route_uri2;
}
#upstream oxcluster_docs {
# server converter_host:8009 weight=50; # route=APP3;
#
# # sticky route $route_cookie1 $route_cookie2 $route_uri1 $route_uri2;
#}
server {
listen 80 default_server;
listen [::]:80 default_server;
# SSL configuration
listen 443 ssl default_server;
listen [::]:443 ssl default_server;
include snippets/ssl.conf;
root /var/www/html;
index index.html;
server_name _;
add_header "X-Frame-Options" "SAMEORIGIN";
# extend mime types
include mime.types;
types {
text/cache-manifest appcache;
application/x-font-ttf ttf;
image/png xpng;
text/css less;
}
gzip on;
gzip_types text/plain text/javascript application/javascript text/css text/xml application/xml text/x-js application/x-javascript;
gzip_vary off;
location = / {
rewrite .* /appsuite/ permanent;
}
location = /appsuite/ {
if ($http_user_agent ~ "MSIE [6-8]") {
rewrite .* /appsuite/unsupported.html permanent;
}
index ui;
}
location /appsuite/ {
location ~ ^/appsuite/v= {
rewrite ^/appsuite/v=[^/]*(/.*)$ /appsuite$1 last;
}
location ~ /(ui|core|signin)$ {
types { }
default_type text/html;
expires 0; # now
if_modified_since off;
etag off;
}
# en_US help fallback
location ~ ^(/appsuite/help(?:-.+)?/l10n)/([a-z_A-Z]+)(.+) {
try_files $uri $uri/index.html $1/en_US$3 $1/en_US$3/index.html =404;
# copied from default below
expires 182d; # about 6 months
add_header "Cache-Control" "private";
etag off;
}
# icons default-theme fallback
location ~ ^(/appsuite/apps/themes)/.*/([^/]+)$ {
try_files $uri $1/icons/default/$2 =404;
# copied from default below
expires 182d; # about 6 months
add_header "Cache-Control" "private";
etag off;
}
location ~ /online\.js$ {
expires 0; # now
add_header "Cache-Control" "no-store, no-cache, must-revalidate, post-check=0, pre-check=0";
etag off;
}
location ~ \.(jsz|cssz|xmlz) {
gzip off;
types {
text/javascript jsz;
text/css cssz;
text/xml xmlz;
}
add_header "Content-Encoding" "gzip";
# copied from default below
expires 182d; # about 6 months
add_header "Cache-Control" "private";
etag off;
}
# else:
expires 182d; # about 6 months
add_header "Cache-Control" "private";
etag off;
}
location @oxcluster {
proxy_pass http://oxcluster;
proxy_read_timeout 100s;
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-Proto $scheme;
# timeout=100 smax=0 ttl=60 retry=60 loadfactor=50 route=APP1
# ProxySet stickysession=JSESSIONID|jsessionid scolonpathdelim=On
# SetEnv proxy-initial-not-pooled
# SetEnv proxy-sendchunked
}
location @eas_oxcluster {
proxy_pass http://oxcluster;
proxy_read_timeout 1900s;
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-Proto $scheme;
# timeout=1900 smax=0 ttl=60 retry=60 loadfactor=50 route=APP1
# ProxySet stickysession=JSESSIONID|jsessionid scolonpathdelim=On
# SetEnv proxy-initial-not-pooled
# SetEnv proxy-sendchunked
}
# location @oxcluster_docs {
# proxy_pass http://oxcluster_docs;
# proxy_read_timeout 100s;
#
# 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-Proto $scheme;
#
# allow backendip;
# deny all;
# }
location /ajax {
error_page 418 = @oxcluster; return 418;
}
location /appsuite/api {
rewrite ^/appsuite/api(.*) /ajax$1 last;
# error_page 418 = @oxcluster; return 418;
}
location /drive {
error_page 418 = @oxcluster; return 418;
}
location /infostore {
error_page 418 = @oxcluster; return 418;
}
location /publications {
error_page 418 = @oxcluster; return 418;
}
location /realtime {
error_page 418 = @oxcluster; return 418;
}
location /servlet {
error_page 418 = @oxcluster; return 418;
}
location /servlet/axis2/services {
allow 127.0.0.1;
deny all;
error_page 418 = @oxcluster; return 418;
}
location /webservices {
allow 127.0.0.1;
deny all;
error_page 418 = @oxcluster; return 418;
}
# location /documentconverterws {
# error_page 418 = @oxcluster_docs; return 418;
# }
location /usm-json {
error_page 418 = @eas:oxcluster; return 418;
}
location /Microsoft-Server-ActiveSync {
error_page 418 = @eas_oxcluster; return 418;
}
# deny access to .htaccess files
location ~ /\.ht {
deny all;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment