<@sys.site id=siteId><#assign a=object/></@sys.site>
<@tools.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(':')
/>
</@tools.disk>
<div class="pageFormContent" layoutH>
    <dl class="nowrap">
        <dt><@t.page 'site'/>:</dt>
        <dd>
            ${(a.name)!}
            <span class="info"><@t.page 'server_config.description'/></span>
        </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,When starting the CMS from the command line, add the -Dcms.initProto=false parameter,For example:java -jar -server -Dcms.initProto=false publiccms.war --&gt;
        &lt;Valve className="org.apache.catalina.valves.RemoteIpValve" protocolHeader="X-Forwarded-Proto" portHeader="X-Forwarded-Port"/&gt;</textarea>
            <span class="info"><@t.page 'server_config.tomcat_description'/></span>
        </dd>
    </dl>
    <div class="tabs">
        <div class="tabsHeader">
            <ul>
                <li><a href="javascript:;" onclick="return false;"><@t.page 'server_config.nginx'/></a></li>
                <li><a href="sysSite/configTemplateApache.html?siteId=${siteId}" class="j-ajax" onclick="return false;"><@t.page 'server_config.apache'/></a></li>
            </ul>
        </div>
       <div class="tabsContent">
            <div class="unitBox">
                <textarea class="code" mode="nginx">
#<@t.page 'server_config.nginx_common_description'/>
upstream cms {
    #<@t.page 'server_config.upstream'/>
    ip_hash;
    server localhost:8080  weight=1;
}

<@sys.domainList 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 <#if dynamicPath=sitePath&&dynamicPort=sitePort&&dynamicLocation=siteLocation>@cmsproxy<#else>${dynamicLocation?has_content?then('/'+dynamicLocation,'/')}</#if> {
        <#if dynamicPath!=sitePath||dynamicPort!=sitePort||dynamicLocation=siteLocation>client_max_body_size 100m;</#if>
        proxy_redirect off;
        proxy_set_header Host $http_host;
        # if not waf
        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_set_header X-Forwarded-Port $server_port;
        # end if not waf
        proxy_set_header Sendfile X-Accel-Redirect;
        proxy_connect_timeout 5;
        proxy_send_timeout 30;
        proxy_read_timeout 10;
        proxy_pass http://cms;
    }
    location /privatefile/ {
        internal;
        alias ${realRootPath}/web/private/site_${siteId}/;
    }
        <#if a.useSsi>
    location /include/ {
        internal;
        alias ${realRootPath}/web/site_${siteId}/include/;
    }
        </#if>
        <#if dynamicPath=sitePath&&dynamicPort=sitePort>
    #${a.name} <@t.page 'server_config.static'/>
    location ${siteLocation?has_content?then('/'+siteLocation,'/')} {
        alias   ${realRootPath}/web/site_${siteId}/;
        index   index.html;
        <#if dynamicLocation=siteLocation>
        client_max_body_size 100m;
        try_files  $uri  @cmsproxy;
        </#if>
    }
            <#if a?has_content && a.hasChild && a.multiple>
                <@sys.siteList parentId=a.id pageSize=100>
                    <#list page.list as a>
                        <#if a.directory?has_content>
    #${a.name} <@t.page 'server_config.static'/>
    location ${siteLocation?has_content?then('/'+siteLocation,'/')}${a.directory}/ {
        alias   ${realRootPath}/web/site_${a.id}/;
        index  index.html;
        <#if dynamicLocation=siteLocation>
        try_files  $uri  @cmsproxy;
        </#if>
    }
                        </#if>
                    </#list>
                </@sys.siteList>
            </#if>
        </#if>

    error_page 403 /error/403.html;
    error_page 404 /error/404.html;
    error_page 500 502 503 504 /error/500.html;
}
</@sys.domainList>
<#if dynamicPath!=sitePath||dynamicPort!=sitePort>
#${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>

    location ${siteLocation?has_content?then('/'+siteLocation,'/')} {
        alias   ${realRootPath}/web/site_${siteId}/;
        index  index.html;
        add_header Access-Control-Allow-Origin *;
    }
    <#if a.useSsi>
    location /include/ {
        internal;
        alias ${realRootPath}/web/site_${siteId}/include/;
    }
    </#if>

    <#if a?has_content && a.hasChild && a.multiple>
        <@sys.siteList parentId=a.id pageSize=100>
            <#list page.list as a>
                <#if a.directory?has_content>
    location ${siteLocation?has_content?then('/'+siteLocation,'/')}${a.directory}/ {
        alias   ${realRootPath}/web/site_${a.id}/;
        index  index.html;
    }
                </#if>
            </#list>
        </@sys.siteList>
    </#if>

    error_page 403 /error/403.html;
    error_page 404 /error/404.html;
    error_page 500 502 503 504 /error/500.html;
}
</#if></textarea>
                <span class="info"><@t.page 'server_config.nginx_config_description'/></span>
            </div>
            <div class="unitBox">loading</div>
        </div>
    </div>
</div>
<div class="formBar">
    <ul>
        <li><button type="button" class="button close"><@t.page 'button.close'/></button></li>
    </ul>
</div>