System Administrator Jahia 8

Jahia and Nginx

Question

How can I configure with Nginx a reverse proxy for Jahia?

Answer

Here is a simple configuration allowing setting up a reverse-proxy:

map $http_upgrade $connection_upgrade {
	default upgrade;
        '' close;
}

upstream jahia {
        server localhost:8080;
}


server {
	listen 80 default_server;
	listen [::]:80 default_server;

	root /var/www/html;

	server_name SERVER_NAME;

	location / {
	        proxy_set_header Host $http_host;
        	proxy_set_header X-Real-IP $remote_addr;
	        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        	proxy_set_header X-Forwarded-Host $http_host;
	        proxy_set_header X-Forwarded-Proto $scheme;
	        proxy_pass http://jahia;
	}


	location /modules/graphqlws {
		proxy_http_version 1.1;
 		proxy_set_header Upgrade $http_upgrade;
		proxy_set_header Connection $connection_upgrade;
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Host $http_host;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_pass http://jahia;
    }

}