<@_sysSite id=siteId><#assign a=object/></@_sysSite>
<@_disk>
<#assign
    realRootPath=rootPath?replace('\\','/')
    dynamicPath=a.dynamicPath?keep_after('//')?keep_before('/')?keep_before(':')
    dynamicLocation=a.dynamicPath?keep_after('//')?keep_after('/')
    dynamicPort=a.dynamicPath?keep_after('//')?keep_before('/')?keep_after(':')
    sitePath=a.sitePath?keep_after('//')?keep_before('/')?keep_before(':')
    siteLocation=a.sitePath?keep_after('//')?keep_after('/')
    sitePort=a.sitePath?keep_after('//')?keep_before('/')?keep_after(':')
/>
</@_disk>
<div class="pageFormContent" layoutH>
    <dl class="nowrap">
        <dt><@t.page 'site'/>:</dt>
        <dd>
            ${(a.name)!}
            <span class="info"><@t.page 'server_config.nginx_description'/></span>
        </dd>
    </dl>
    <dl class="nowrap">
        <dt><@t.page 'server_config.nginx'/>:</dt>
        <dd>
            <textarea class="code" mode="nginx">
<@_sysDomainList advanced=true siteId=siteId>
#${a.name} <@t.page 'server_config.site'/>
server {
    listen       ${dynamicPort?has_content?then(dynamicPort,80)};
    #listen 443 ssl;
    server_name  ${dynamicPath} <#list page.list as d><#if d.name!=dynamicPath>${d.name}</#if><#if d.wild> *.${d.name}</#if><#sep> </#list>;
    
    #ssl_certificate cert/xxx.pem;
    #ssl_certificate_key cert/xxx.key;
     
        <#if a.useSsi>
    ssi on;
    ssi_silent_errors on;
        </#if>
    location ${dynamicLocation?has_content?then('/'+dynamicLocation,'/')} {
        client_max_body_size 20m;
        proxy_redirect off;
        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;
        proxy_connect_timeout 5;
        proxy_send_timeout 30;
        proxy_read_timeout 10;
        proxy_pass http://cms;
        
        #<@t.page 'server_config.proxy'/>
        #proxy_pass http://cms/publiccms/;
        #proxy_cookie_path /publiccms/ /;
        #rewrite /publiccms/(.*)$ /$1 last;
    }

        <#if a.useSsi>
    location /include/ {
        alias ${realRootPath}/web/site_${siteId}/include/;
    }
        </#if>
        <#if dynamicPath=sitePath&&dynamicLocation!=siteLocation>
    #${a.name} <@t.page 'server_config.static'/>
    location ${siteLocation?has_content?then('/'+siteLocation,'/')} {
        alias   ${realRootPath}/web/site_${siteId}/;
        index  index.html;
    }
        <#else>
    location ${dynamicLocation?has_content?then('/'+dynamicLocation,'/')}webfile/ {
        alias   ${realRootPath}/web/site_${siteId}/webfile/;
        index  index.html;
    }
        </#if>
}
</@_sysDomainList>
<#if dynamicPath!=sitePath||dynamicPort!=sitePort||!(dynamicPath=sitePath&&dynamicLocation!=siteLocation)>
#${a.name} <@t.page 'server_config.static'/>
server {
    listen       ${sitePort?has_content?then(sitePort,80)}; #<@t.page 'server_config.port'/>
    server_name  ${sitePath};
    <#if a.useSsi>
    ssi on;
    ssi_silent_errors on;
    ssi_types text/shtml;

        <#if siteLocation?has_content>
    location /include/ {
        alias ${realRootPath}/web/site_${siteId}/include/;
    }
        </#if>
    </#if>

    location ${siteLocation?has_content?then('/'+siteLocation,'/')} {
        alias   ${realRootPath}/web/site_${siteId}/;
        index  index.html;
        add_header Access-Control-Allow-Origin *;
    }
}
</#if></textarea>
            <span class="info"><@t.page 'server_config.nginx_config_description'/></span>
        </dd>
    </dl>
    <dl class="nowrap">
        <dt><@t.page 'server_config.nginx_common'/>:</dt>
        <dd><textarea class="code" mode="nginx">
upstream cms {
    #<@t.page 'server_config.upstream'/>
    ip_hash;
    server localhost:8080  weight=1;
}</textarea>
            <span class="info"><@t.page 'server_config.nginx_common_description'/></span>
        </dd>
    </dl>
    <dl class="nowrap">
        <dt><@t.page 'server_config.apache'/>:</dt>
        <dd>
            <textarea class="code" mode="xml">
#${a.name} <@t.page 'server_config.site'/>
<Directory "${realRootPath}/web/site_${siteId}/">
    AllowOverride None
    Options Indexes FollowSymLinks Includes
    Require all granted
</Directory>

<VirtualHost *:${dynamicPort?has_content?then(dynamicPort,80)}>
   ServerName ${dynamicPath}
<@_sysDomainList advanced=true siteId=siteId>
  <#if page.totalCount gt 0>
   ServerAlias <#list page.list as d><#if d.name!=dynamicPath&&d.name!=sitePath>${d.name}</#if><#if d.wild> *.${d.name}</#if><#sep> </#list>
  </#if>
</@_sysDomainList>
  <#if a.useSsi>
   alias /include/ "${realRootPath}/web/site_${siteId}/include/"
   AddType text/html .html .shtml
   AddOutputFilter INCLUDES .html .shtml
  </#if>
   ProxyRequests off
   ProxyPreserveHost On
   ProxyPass ${dynamicLocation?has_content?then('/'+dynamicLocation,'/')} http://localhost:8080${dynamicLocation?has_content?then('/'+dynamicLocation,'/')}
   ProxyPassReverse ${dynamicLocation?has_content?then('/'+dynamicLocation,'/')} http://localhost:8080${dynamicLocation?has_content?then('/'+dynamicLocation,'/')}
   
   <#if dynamicPath=sitePath&&dynamicLocation!=siteLocation>
   #${a.name} <@t.page 'server_config.static'/>
   Alias "/${siteLocation}" "${realRootPath}/web/site_${siteId}/"
   <#else>
   Alias "${dynamicLocation?has_content?then('/'+dynamicLocation,'/')}webfile/" "${realRootPath}/web/site_${siteId}/webfile/"
   </#if>
</VirtualHost>

<#if dynamicPath!=sitePath||dynamicPort!=sitePort||!(dynamicPath=sitePath&&dynamicLocation!=siteLocation)>
#${a.name} <@t.page 'server_config.static'/>
<VirtualHost *:${sitePort?has_content?then(sitePort,80)}>
    ServerName ${sitePath}    
    <#if a.useSsi>
        <#if siteLocation?has_content>
   alias /include/ "${realRootPath}/web/site_${siteId}/include/"
   AddType text/html .html .shtml
   AddOutputFilter INCLUDES .html .shtml
        </#if>
    </#if>
    <#if siteLocation?has_content>
    Alias "/${siteLocation}/" "${realRootPath}/web/site_${siteId}/"
    <#else>
    DocumentRoot "${realRootPath}/web/site_${siteId}/" 
    </#if>
    <IfModule headers_module>
        Header set Access-Control-Allow-Origin "*"
    </IfModule>
</VirtualHost>
</#if>
</textarea>
        </dd>
    </dl>
    <dl class="nowrap">
        <dt><@t.page 'server_config.tomcat'/>:</dt>
        <dd><textarea class="code" mode="xml">
&lt;!-- this valve replaces the apparent client remote IP address and hostname and scheme for the request --&gt;
&lt;Valve className="org.apache.catalina.valves.RemoteIpValve" protocolHeader="X-Forwarded-Proto"/&gt;</textarea>
            <span class="info"><@t.page 'server_config.tomcat_description'/></span>
        </dd>
    </dl>
</div>
<div class="formBar">
    <ul>
        <li><button type="button" class="button close"><@t.page 'button.close'/></button></li>
    </ul>
</div>