## A Debian 9 Nginx configuration, should work with Nginx >= v1.10.3
#
# This configuration reverse-proxies to a PGWI_Server run with the
# "waitress" WSGI webserver, or similar.
#
# Most people will want to change the "server_name" configuration parameter.
#
##
# You should look at the following URL's in order to grasp a solid
# understanding of Nginx configuration files in order to fully unleash
# the power of Nginx.
# https://www.nginx.com/resources/wiki/start/
# https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/
# https://wiki.debian.org/Nginx/DirectoryStructure
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##

# Default server configuration
#
server {
	listen 80 default_server;
	listen [::]:80 default_server;

	# SSL configuration
	#
	# listen 443 ssl default_server;
	# listen [::]:443 ssl default_server;
	#
	# Note: You should disable gzip for SSL traffic.
	# See: https://bugs.debian.org/773332
	#
	# Read up on ssl_ciphers to ensure a secure configuration.
	# See: https://bugs.debian.org/765782
	#
	# Self signed certs generated by the ssl-cert package
	# Don't use them in a production server!
	#
	# include snippets/snakeoil.conf;

	root /var/www/html;

	# Add index.php to the list if you are using PHP
	index index.html index.htm;

	server_name _;

	location / {
		# First attempt to serve request as file, then
		# as directory, then fall back to displaying a 404.
		try_files $uri $uri/ =404;
	}

        location / {  # Root of PGWUI resource component in URLs
                      # (Typically the same as the pgwui.route_prefix
                      # configuration setting.)
                      # E.g. "location/pgwui/" means access to pgwui
                      # via urls beginning: http://example.com/pgwui/
            proxy_pass       http://127.0.0.1:6543;
            # Using $http_host relies on the client, but is useful
            # because it preserves the original URL's port when
            # ssh tunneling.  If the client does not send the HOST
            # header than it may be necessary to use $host instead.
            proxy_set_header Host      $http_host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_redirect default;
        }
}
