Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON encrypted/compressed over HTTPS #4

Closed
cwilby opened this issue Jul 24, 2018 · 5 comments
Closed

JSON encrypted/compressed over HTTPS #4

cwilby opened this issue Jul 24, 2018 · 5 comments

Comments

@cwilby
Copy link

cwilby commented Jul 24, 2018

After deploying this app to a DigitalOcean droplet I was able to connect my local composer instance and install dependencies.

After enabling HTTP on the server using LetsEncrypt, composer is no longer able to fetch package.json as it appears encrypted/compressed.

I have tried enabling/disabling gzip to no avail.

Update: the file is encrypted/encoded on the server when opened with sudo nano package.json.

@cwilby
Copy link
Author

cwilby commented Jul 24, 2018

This is the output I get:

Composer version 1.6.5 2018-05-04 11:44:59


  [Seld\JsonLint\ParsingException]
  "" does not contain valid JSON
  Parse error on line 1:
  composer
  ^
  Expected one of: 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '['


config [-g|--global] [-e|--editor] [-a|--auth] [--unset] [-l|--list] [-f|--file FILE] [--absolute] [--] [<setting-key>] [<setting-value>]...```

@webysther
Copy link
Owner

webysther commented Jul 24, 2018

Hi @cameronwilby, there a feature, i lack to explain on a tutorial to create your own mirror, next few days i fixed this problem.

The mirror creation save all data as .gz to save disk space, you need to enable reverse gz decode when a client ask for the decompressed version.

To do this, change you nginx configuration of gzip_static and gunzip as is:

server {
    index.html;

    server_name packagist.com.br www.packagist.com.br;

    location / {
        try_files $uri $uri/ =404;
        gzip_static on;
        gunzip on;
    }
}

Source:
http://nginx.org/en/docs/http/ngx_http_gunzip_module.html
http://nginx.org/en/docs/http/ngx_http_gzip_static_module.html

@cwilby
Copy link
Author

cwilby commented Jul 25, 2018

@webysther that did the trick, thank you! Here is the nginx config I ended up with:

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

	root /var/www/html;
	index index.php index.html index.htm;

	server_name packagist.com.br;

	location / {
		try_files $uri $uri/ =404;
		gzip_static on;
		gunzip on;
	}

	error_page 404 /404.html;
	error_page 500 502 503 504 /50x.html;
	location = /50x.html {
		root /usr/share/nginx/html;
	}

	location ~ \.php$ {
	        include snippets/fastcgi-php.conf;
        	fastcgi_pass unix:/run/php/php7.2-fpm.sock;
	}

	listen [::]:443 ssl ipv6only=on
	listen 443 ssl;
	ssl_certificate /etc/letsencrypt/live/packagist.com.br/fullchain.pem;
	ssl_certificate_key /etc/letsencrypt/live/packagist.com.br/privkey.pem;
	include /etc/letsencrypt/options-ssl-nginx.conf;
	ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
}

@cwilby cwilby closed this as completed Jul 25, 2018
@webysther
Copy link
Owner

Great @cameronwilby! Another tip is using a machine with 2GB at least of memory. With that all metadata keep to the memory helping the nginx and disk to not be consumed.

@cwilby
Copy link
Author

cwilby commented Jul 25, 2018

Good to know, I went with the 2GB droplet on DigitalOcean 👍 Thanks again @webysther, awesome work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants