Skip to content
Philip Helger edited this page Jul 14, 2020 · 1 revision

Running behind an nginx

It is possible to run the SMP on an Tomcat (or the like) that is proxied via an nginx to the public. In this case and the SMP runs on Tomcat in a context different than ROOT, it is important to

  • set the smp.forceroot configuration property to true (see Configuration for details) and
  • to change the path of the SMP session cookie (usually JSESSIONID) from the original path to the destination path as well

By default nginx uses HTTP 1.0 so it is important to add the proxy-statement to switch to HTTP 1.1. The name peppolXX is just a placeholder that you can change. The XX is just added to clearly identify where the placeholder is used. The following configuration assumes that the SMNP software is running on Tomcat on the same host on port 8080 in the context /smp. The public DNS name of the server in the below configuration is smp.example.org.

The second server_name property is required to take arbitrary requests from Peppol SMK based requests (server_name *.acc.edelivery.tech.ec.europa.eu). For Peppol production SML usage, change this to server_name *.edelivery.tech.ec.europa.eu. Hint: when proxying test and production with the same nginx instance, ensure the order is correct, as the production URLs are a subset of the test URLs (so test must come before production).

upstream peppolXX {
  server  127.0.0.1:8080;
}

server {
  listen 80;
  server_name smp.example.org;
  server_name *.acc.edelivery.tech.ec.europa.eu;

  location / {
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Server $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $host;
    proxy_cookie_path /smp /;
    proxy_http_version 1.1;
    proxy_pass http://peppolXX/smp/;
  }
}