nginx Directive Snippets not save correctly in vhost file

Discussion in 'Installation/Configuration' started by skysky, Mar 30, 2022.

  1. skysky

    skysky Member

    Hi,

    when I put below codes into nginx Directives and saved. the vhost file that ispconfig updated, does not contain the exact codes I put. IT REMOVED SOME OF THE CODES. why?

    Here are the codes I put:

    # Add more these config if does not have

    if ($scheme != "https") {
    rewrite ^ https://$http_host$request_uri? permanent;
    }

    location / {

    if ($prerender = 1) {
    rewrite (.*) /prerenderio last;
    }
    try_files $uri $uri/ /index.html;
    }

    location /prerenderio {
    if ($prerender = 0) {
    return 404;
    }

    proxy_set_header X-Prerender-Token dfdsfd;

    proxy_hide_header Cache-Control;
    add_header Cache-Control "private,max-age=600,must-revalidate";

    #resolve using Google's DNS server to force DNS resolution and prevent caching of IPs
    resolver 8.8.8.8 8.8.4.4;
    set $prerender_host "service.prerender.io";
    proxy_pass https://$prerender_host;
    rewrite .* /$scheme://$host$request_uri? break;
    }

    location ~* ^/(\.well-known/)?apple-app-site-association {
    default_type application/json;
    }

    location /apple-app-site-association {
    default_type application/json;
    }



    # AppBuilder Webapp

    # Add more these config if does not have

    location / {
    try_files $uri $uri/ /index.html;
    }



    # AppBuilder Iframe

    # Add more these config if does not have

    location / {
    try_files $uri $uri/ /index.html;
    }

    HERE ARE THE CODE ISPCONFIG UPDATED FOR THE DOMAIN VHOST FILE

    if ($scheme != "https") {
    rewrite ^ https://$http_host$request_uri? permanent;
    }

    location / {
    try_files $uri $uri/ /index.html;
    }

    location /prerenderio {
    if ($prerender = 0) {
    return 404;
    }

    proxy_set_header X-Prerender-Token dfdsfd;

    proxy_hide_header Cache-Control;
    add_header Cache-Control "private,max-age=600,must-revalidate";

    resolver 8.8.8.8 8.8.4.4;
    set $prerender_host "service.prerender.io";
    proxy_pass https://$prerender_host;
    rewrite .* /$scheme://$host$request_uri? break;
    }

    location ~* ^/(\.well-known/)?apple-app-site-association {
    default_type application/json;
    }

    location /apple-app-site-association {
    default_type application/json;
    }
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Most likely nginx refused your config because you used the same location / twice. Check the nginx sites-available folder if there is a vhost with .err file ending, if yes, then nginx rejected your config and ISPConfig had to revert to the last working config. You can also use the debug mode in ISPConfig to debug things and please put configs in code tags here in the forum.
     
    ahrasis likes this.
  3. skysky

    skysky Member

    you are right about this: Most likely nginx refused your config because you used the same location / twice.
    remove and working.

    thanks.
     

Share This Page