Skip to content

Fixed problem to switch to https with a nginx proxy #887

@Zatalyz

Description

@Zatalyz

I share a solution with you; I saw that there had been a few closed tickets on the subject, unfortunately without a relevant solution for my case. This will probably help others. Maybe it can improve FAQ or documentation :)

The situation :
I have a server with proxmox. All the traffic arrives at a first VM that serves as a proxy. Freescout is on another VM and receives traffic from this proxy. Unfortunately, the basic configuration didn't work: either we have mixed content (some of the links rewritten in https but not all of them) if the freescout .env is set with APP_FORCE_HTTPS=FALSE; or the site is inaccessible when we switch to APP_FORCE_HTTPS=TRUE, because Freescout's VM doesn't have ssl (certificat is on the proxy).

The trick is to add the parameter fastcgi_param HTTPS on; in one of the blocks of the conf nginx of the freescout VM, in the part location ~ \.php$.

On the proxy, the nginx configuration looks like this :


server {
	listen      10.0.0.10:80;
	server_name "freescout.mydomain.org";

	return      301 https://freescout.mydomain.org$request_uri;
}

server {
	listen      10.0.0.10:443 ssl http2;
	server_name "freescout.mydomain.org";

	ssl_certificate /etc/letsencrypt/live/freescout.mydomain.org/fullchain.pem;
	ssl_certificate_key /etc/letsencrypt/live/freescout.mydomain.org/privkey.pem;
	location / {
		proxy_set_header    Host $host;
		proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;
		proxy_pass          http://10.0.0.13/;
	}
}

And on the VM Freescout, the nginx configuration look like this :


server {
	listen 80;
	listen [::]:80;
 
	server_name freescout.mydomain.org;
 
	root /var/www/freescout/public;
 
	index index.php index.html index.htm;
 
	error_log /var/www/freescout/storage/logs/web-server.log;
 
	location / {
		try_files $uri $uri/ /index.php?$query_string;
	}
	location ~ \.php$ {
		fastcgi_split_path_info ^(.+\.php)(/.+)$;
		fastcgi_pass unix:/run/php/php7.3-fpm.sock;
		fastcgi_index index.php;
		fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
		include fastcgi_params;
		fastcgi_param HTTPS on;
	}
	# Uncomment this location if you want to improve attachments downloading speed.
	# Also make sure to set APP_DOWNLOAD_ATTACHMENTS_VIA=nginx in the .env file.
	#location ^~ /storage/app/attachment/ {
	#    internal;
	#    alias /var/www/html/storage/app/attachment/;
	#}
	location ~* ^/storage/attachment/ {
		expires 1M;
		access_log off;
		try_files $uri $uri/ /index.php?$query_string;
	}
	location ~* ^/(?:css|js)/.*\.(?:css|js)$ {
		expires 2d;
		access_log off;
		add_header Cache-Control "public, must-revalidate";
	}
	location ~* ^/(?:css|fonts|img|installer|js|modules|[^\\\]+\..*)$ {
		expires 1M;
		access_log off;
		add_header Cache-Control "public";
	}
	location ~ /\. {
		deny  all;
	}
}

Now, it's work and all is on https !

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions