Confinity Documentation
  • Latest Version
  • Latest Version
  • Getting Started

    • Introduction
    • Core Concepts
    • Create an Application
    • Glossary
  • Essentials

    • Authentication & SSO
    • Breaking Changes
    • Roslyn Source Analyzers
    • Changelog
    • ConfinityContent
    • ConfinitySelectable
    • Confinity Schedules
    • Data Seeding
    • Development guidelines [WIP]
    • Entity App
    • Entity Form
    • Entity Permissions
    • Frontend Configuration
    • Images
    • Known Issues
    • Localization
    • Migrations
    • Modules [WIP]
    • On-Site Editing
    • Settings
    • Cascade Delete
    • Replication
    • Infrastructure
  • Modules

    • Analytics Module
    • Assets Module
    • Blog Module
    • Cookie Consent Module
    • Forms Module
    • Friendly Captcha (Forms Module )
    • GeoIP Module
    • Htmx
    • Mail Module
    • Mailing Module
    • MediaPlayer Module
    • GoogleMyBusiness Module
    • OpenTelemetry Module
    • Pages Module [WIP]
    • Pattern Library Module
    • SIX Saferpay (worldline) Module
    • Products Module
    • Search Module
    • Wizard Module
  • Guides

    • Create a Custom Entity App Form Element
    • Date and Time
    • Entity Change Listener
    • File Upload / Temp File
    • HTTP security headers
    • conventions [WIP]
    • How to use Confinity with nginx
    • Notifications
    • Nullability
    • Rename Entity
    • Schedules
    • Useful snippets
    • Content Localization
  • Design Guidelines

    • Introduction
    • Page Components
    • Forms Module

How to use Confinity with nginx

Configuration as Reverse Proxy

Nginx Configuration

The following configuration is a good starting point when nginx is used as a reverse proxy.

http {
 	map $http_connection $connection_upgrade {
		"~*Upgrade" $http_connection;
		default keep-alive;
	}

	server {
		listen 80;
		server_name  _;

		location / {
			proxy_pass http://localhost:5000; # <- where your application is running
			
			proxy_set_header   	Host $host;
			proxy_set_header   	X-Forwarded-Host $host;
			proxy_set_header   	X-Forwarded-For $proxy_add_x_forwarded_for;
			proxy_set_header   	X-Forwarded-Proto $scheme;
			
			# asset app upload
			client_max_body_size 10M; 
			
			# Configuration for WebSockets
			proxy_set_header Upgrade $http_upgrade;
			proxy_set_header Connection $connection_upgrade;
			proxy_cache off;
			
			# WebSockets were implemented after http/1.0
			proxy_http_version 1.1;

			# Configuration for ServerSentEvents
			proxy_buffering off;

			# Configuration for LongPolling or if your KeepAliveInterval is longer than 60 seconds
			proxy_read_timeout 100s;
		}
	}
}

It is very important having the three marked lines in the configuration, so the application can access the original host, schema and source IP address of the HTTP request. Otherwise Confinity won't be able to create links with correct schema and hostnames.

Application Configuration

In order your application will work properly with a reverse proxy, you have to configure the Forwarded Headers Middleware accordingly. Add the following line before any other middleware.

app.UseForwardedHeaders(new ForwardedHeadersOptions { ForwardedHeaders = ForwardedHeaders.All });

You can find more information about the configuration for the Forwarded Headers Middleware in the official documentation .

Important if the proxy and the application are not running on the same

machine, you have to configure the properties KnownNetworks or KnownProxies in the ForwardedHeadersOptions.

// example
services.Configure<ForwardedHeadersOptions>(options =>
{
    options.ForwardedHeaders =
        ForwardedHeaders.XForwardedFor
        | ForwardedHeaders.XForwardedProto
        | ForwardedHeaders.XForwardedHost;
    options.KnownProxies.Add(IPAddress.Parse("192.168.66.225"));
});
...
app.UseForwardedHeaders();
Prev
conventions [WIP]
Next
Notifications