How to do map variables for nginx through ispconfig?

Discussion in 'ISPConfig 3 Priority Support' started by pvanthony, May 23, 2025.

  1. pvanthony

    pvanthony Active Member HowtoForge Supporter

    I am trying to setup a proxy for headscale through ispconfig.
    The documentation I following is as follows.
    https://headscale.net/stable/ref/integration/reverse-proxy/?h=proxy#nginx
    I get error when add the following in the website options in ispconfig.

    Code:
    map $http_upgrade $connection_upgrade {
        default      upgrade;
        ''           close;
    }
    
    The following is accepted without error in the website options.
    Code:
        location / {
            proxy_pass http://<IP:PORT>;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection $connection_upgrade;
            proxy_set_header Host $server_name;
            proxy_redirect http:// https://;
            proxy_buffering off;
            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;
            add_header Strict-Transport-Security "max-age=15552000; includeSubDomains" always;
        }
    
    I got it to work by going in command line to the nginx config and adding the map config on top of the nginx configuration for the website.
    My question is, is there a way to add the map config through the ispconfig web ui?
    So that the config will stay when we save the setting in the future.
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    No, as the map needs to be outside of the vhost and nginx directives go into the vhost.

    You can prevent the config from being altered by using chattr +i nnnnnnn.vhost on the vhost file in sites-available. But this will prevent all changes from ISPConfig on that vhost. To remove the protection, use chattr -i nnnnnnn.vhost as you won't be able to edit that file anymore even as root user.
     
    Last edited: May 24, 2025
    pvanthony likes this.
  3. pvanthony

    pvanthony Active Member HowtoForge Supporter

    Thank you for the advice. Good to know this.
     
  4. nhybgtvfr

    nhybgtvfr Well-Known Member HowtoForge Supporter

    pvanthony likes this.
  5. pvanthony

    pvanthony Active Member HowtoForge Supporter

    This is a cool idea. I did not think about it. I will test it out.
    Thank you for sharing this idea. I do appreciate it.
     

Share This Page