[
  {
    "path": "Portal.mustache",
    "content": "{{#ReverseProxy}}\nserver {\n    listen {{port}}{{#https}} ssl{{/https}}{{#https.http2}} http2{{/https.http2}}{{#reuseport}} reuseport{{/reuseport}}{{^fqdn}} default_server{{/fqdn}};\n    listen [::]:{{port}}{{#https}} ssl{{/https}}{{#https.http2}} http2{{/https.http2}}{{#reuseport}} reuseport{{/reuseport}}{{^fqdn}} default_server{{/fqdn}};\n\n    {{#resolver}}\n    resolver {{resolver}};\n    set $backend \"{{backend}}\";\n    {{/resolver}}\n\n    server_name {{#fqdn}}{{fqdn}}{{/fqdn}}{{^fqdn}}_{{/fqdn}};\n\n    {{#https.certificate}}\n    ssl_certificate {{https.certificate}};\n    {{/https.certificate}}\n    {{#https.key}}\n    ssl_certificate_key {{https.key}};\n    {{/https.key}}\n\n    {{#https.hsts}}\n    {{> /usr/syno/share/nginx/HSTS}}\n    {{/https.hsts}}\n\n    location / {\n        proxy_set_header        Host                $http_host;\n        proxy_set_header        X-Real-IP           $remote_addr;\n        proxy_set_header        X-Forwarded-For     $proxy_add_x_forwarded_for;\n        proxy_set_header        X-Forwarded-Proto   $scheme;\n        proxy_intercept_errors  on;\n        proxy_http_version      1.1;\n                proxy_set_header                Upgrade $http_upgrade;\n                proxy_set_header                Connection \"upgrade\";\n                proxy_read_timeout              86400;\n        {{#resolver}}\n        proxy_pass $backend;\n        {{/resolver}}\n        {{^resolver}}\n        proxy_pass {{backend}};\n        {{/resolver}}\n    }\n\n    {{#letsencrypt}}\n    {{> /usr/syno/share/nginx/LetsEncrypt}}\n    {{/letsencrypt}}\n}\n{{/ReverseProxy}}\n"
  },
  {
    "path": "Portal.mustache.dist",
    "content": "{{#ReverseProxy}}\nserver {\n    listen {{port}}{{#https}} ssl{{/https}}{{#https.http2}} http2{{/https.http2}}{{#reuseport}} reuseport{{/reuseport}}{{^fqdn}} d    efault_server{{/fqdn}};\n    listen [::]:{{port}}{{#https}} ssl{{/https}}{{#https.http2}} http2{{/https.http2}}{{#reuseport}} reuseport{{/reuseport}}{{^fqd    n}} default_server{{/fqdn}};\n\n    {{#resolver}}\n    resolver {{resolver}};\n    set $backend \"{{backend}}\";\n    {{/resolver}}\n\n    server_name {{#fqdn}}{{fqdn}}{{/fqdn}}{{^fqdn}}_{{/fqdn}};\n\n    {{#https.certificate}}\n    ssl_certificate {{https.certificate}};\n    {{/https.certificate}}\n    {{#https.key}}\n    ssl_certificate_key {{https.key}};\n    {{/https.key}}\n\n    {{#https.hsts}}\n    {{> /usr/syno/share/nginx/HSTS}}\n    {{/https.hsts}}\n\n    location / {\n        proxy_set_header        Host                $http_host;\n        proxy_set_header        X-Real-IP           $remote_addr;\n        proxy_set_header        X-Forwarded-For     $proxy_add_x_forwarded_for;\n        proxy_set_header        X-Forwarded-Proto   $scheme;\n        proxy_intercept_errors  on;\n        proxy_http_version      1.1;\n        {{#resolver}}\n        proxy_pass $backend;\n        {{/resolver}}\n        {{^resolver}}\n        proxy_pass {{backend}};\n        {{/resolver}}\n    }\n\n    {{#letsencrypt}}\n    {{> /usr/syno/share/nginx/LetsEncrypt}}\n    {{/letsencrypt}}\n}\n{{/ReverseProxy}}\n"
  },
  {
    "path": "README.md",
    "content": "# dsm-reverse-proxy-websocket\nConfiguration fix for Synology DSM 6 reverse proxy to handle websocket\n\n**Starting from  DSM 6.2.1, this modification is no longer required, as Application Portail has an option to handle websocket.  \nIt's even not recommended to modify your `Portal.mustache` file, as it will cause error when adding or edition reverse proxy entries in Application Portal.**\n\nIn DSM 6.2.1+, when editing a reverse proxy entry in Application Portal, go to \"custom headers\" tab and click the arrow on the \"Create\" button, then \"Websocket\". This will add the required headers for websocket to this reverse proxy.\n\n**BACKUP YOUR `portal.mustache` BEFORE MODIFYING IT!**\n\nYou need to edit the file `/usr/syno/share/nginx/Portal.mustache` to add the followings in the `location` section:\n\n```\nproxy_set_header Upgrade $http_upgrade;\nproxy_set_header Connection \"upgrade\";\nproxy_read_timeout 86400;\n```\n\nThen restart the httpd with: \n```\nsudo synoservicecfg --restart nginx\n```\n\n*This will restart ALL http service running, not only reverse proxy, as a single instance of NGinX runs everything.*\n\n\nA modified `Portal.mustache` is provided in this repo (warning: based on DSM 6.1.6-15266).\n\n# Known DSM upgrade impacts on the `Portal.mustache` file\n\n> In **bold** versions overwriting the `Portal.mustache`\n\n- **6.2.1-23824** : overwrites the `Portal.mustache` with a completly new template. **Starting from this version, hacking files are not required anymore as Application Portail reverse proxy feature now has an option to handle websocker.**\n\n- **6.2-23739** : overwrites the `Portal.mustache`\n- **6.1.7-15284** : overwrites the `Portal.mustache`\n- 6.1.6-15266-1 : leaves the `Portal.mustache` file unchange\n- **6.1.6-15266** : overwrites the `Portal.mustache`\n- 6.1.3-15152-1 : leaves the `Portal.mustache` file unchange\n- **6.1.3-15152** : overwrites the `Portal.mustache`\n- **6.1.2-15132** : overwrites the `Portal.mustache`\n- 6.1.1-15101-4 : leaves the `Portal.mustache` file unchange\n- **6.1.1-15101** : overwrites the `Portal.mustache`\n"
  }
]