#
# RESTCONF server configuration
#
server {
    listen 80;
    listen [::]:80;

    ### CHANGE ServerName TO YOUR DOMAIN NAME!!!
    server_name localhost;

    ### Set the root to /var/www/yang-api for all locations
    root /var/www/yang-api;

    ### need to install fcgiwrap to use RESTCONF
    ### set SCRIPT_FILENAME to the location of the restconf program
    location /restconf {

        ### Disable gzip (it makes scripts slower since they have to complete
        ### before getting gzipped)
        gzip                    off;

        ### Fastcgi socket
        fastcgi_pass            unix:/var/run/fcgiwrap.socket;

        ### Fastcgi parameters, include the standard ones
        include                 /etc/nginx/fastcgi_params;

        ### Actual executable
        fastcgi_param           SCRIPT_NAME restconf;

        ### Complete path to the script.
        ### When set, overrides DOCUMENT_ROOT and SCRIPT_NAME
        fastcgi_param           SCRIPT_FILENAME /var/www/yang-api/restconf;

        ### When set (e.g., to ""), disables fastcgiwrap output buffering.
        ### MUST be set if SSE used!
        ### Only available in fcgiwrap version 1.1.0-11 and higher!
        ### Only available on Debian maintained version of fcgiwrap!
        ### RPM users may choose to patch their fcgiwrap.c file to add
        ### NO_BUFFERING functionality.
        ### https://github.com/gnosek/fcgiwrap/pull/48/files
        fastcgi_param           NO_BUFFERING "";

        ### RESTCONF SSE keepalive timeout in seconds
        ### type uint16 { range "0 | 5..3600"; }
        ### Server sends SSE comment ':SSE keepalive' at timeout
	### 0 = do not use (default)
	### suggest 30 - 120 (must be less than fastcgi_read_timeout)
        #fastcgi_param          SSE_KEEPALIVE 30;

        ### When buffering is disabled, the response is passed to a
        ### client synchronously, immediately as it is received.
        ### Nginx will not try to read the whole response from the
        ### FastCGI server.
        ### MUST be set if SSE used
        fastcgi_buffering       off;

        ### This is the maximum time limit for request handling.
        ### If a FastCGI request does not complete within this timeout
        ### seconds, it will be subject to termination.
        ### Set to big number if SSE used
        fastcgi_read_timeout    120s;
    }

    location /.well-known {
        default_type application/xrd+xml;
        etag off;
        add_header Last-Modified "";
    }

}