class_docstr: Nginx keeps track of registered domains, updates nginx config and issues SSL certificates.
  Its internal state could be serialized to a file and restored from it using pydantic.
class_docstr_tok: ["Nginx","keeps","track","of","registered","domains",",","updates","nginx","config","and","issues","SSL","certificates",".","Its","internal","state","could","be","serialized","to","a","file","and","restored","from","it","using","pydantic","."]
code: def get_ssl_conf(domain: str) -> dict:
      return {
          "listen 443": "ssl",
          "ssl_certificate": f"/etc/letsencrypt/live/{domain}/fullchain.pem",
          "ssl_certificate_key": f"/etc/letsencrypt/live/{domain}/privkey.pem",
          "include": "/etc/letsencrypt/options-ssl-nginx.conf",
          "ssl_dhparam": "/etc/letsencrypt/ssl-dhparams.pem",
          # do not force https for localhost
          # we rely on ordered dict (3.8+)
          "set $force_https": "1",
          'if ($scheme = "https")': {
              "set $force_https": "0",
          },
          "if ($remote_addr = 127.0.0.1)": {
              "set $force_https": "0",
          },
          "if ($force_https)": {
              "return": "301 https://$host$request_uri",
          },
      }
  
file_path: dstack/gateway/src/dstack/gateway/services/nginx.py
imports: import logging
  import re
  import subprocess
  import tempfile
  from asyncio import Lock
  from functools import lru_cache
  from pathlib import Path
  from typing import Any, Dict, List, Optional, Set, Tuple, Union
  from pydantic import BaseModel
  from dstack.gateway.common import run_async
  from dstack.gateway.errors import GatewayError
label_desc: Use image node_id 3 for calling the Nginx obj's underlying member method code with example usage: obj.get_ssl_conf(domain) and returns: dict