Chevereto使用docker启动,nginx开启https

what

To solve some problems

  • some web only use markdown and can’t upload pictures,such as v2ex.com
  • some pics you don’t want to give it to others for long time,such as your interesting story
  • give your blog’s can speed when download bigger pics
  • and so on

Picture Bed can offer you a excellent platform to share your pictures and protect them, however it has a problem that you need a server to run the service,even though you can use 七牛云,alioss,weibo for free.

why

Chevereto is aim what I find

  • dockerhub has chevereto images
  • Combined with ShareX (only for windows😢),chevereto can write markdown essay easily
  • it has api ,you can make it stronger
  • Chevereto Free v1.2.2 now
  • Something others you can discover by yourself

how

Chevereto is a php project , I use docker to run it

docker pull nmtan/chevereto:latest

//use docker-compose.yml(next block)

// or docker run 
docker run -it --name chevereto -d     -p 8000:80     -v "/home/xxx/images":/var/www/html/images     -e "CHEVERETO_DB_HOST=127.0.0.1"     -e "CHEVERETO_DB_USERNAME=root"     -e "CHEVERETO_DB_PASSWORD=rootpass"     -e "CHEVERETO_DB_NAME=chevereto"     -e "CHEVERETO_DB_PREFIX=chv_"  nmtan/chevereto
//-v save photos in server instead of container
//-e mysql:5.7.31 host,username,password,db_name(db must exist first)
//open chrome and input 127.0.0.1:8000

//this is docker-compose.yml
version: '3'

services:
  db:
    image: mariadb
    volumes:
      - ./database:/var/lib/mysql:rw
    restart: always
    networks:
      - private
    environment:
      MYSQL_ROOT_PASSWORD: xxxxx
      MYSQL_DATABASE: xxxxx
      MYSQL_USER: xxxxx
      MYSQL_PASSWORD: xxxxx

  chevereto:
    depends_on:
      - db
    image: nmtan/chevereto
    restart: always
    networks:
      - private
    environment:
      CHEVERETO_DB_HOST: db
      CHEVERETO_DB_USERNAME: xxxxxx
      CHEVERETO_DB_PASSWORD: xxxxx
      CHEVERETO_DB_NAME: xxxxx
      CHEVERETO_DB_PREFIX: chv_
    volumes:
      - ./images:/var/www/html/images:rw
      - ./php.ini:/usr/local/etc/php/php.ini:ro
    ports:
      - 8080:80

networks:
  private:

// start command
nohup docker-compose up  &> run.log &
disown

You maybe run into a stone wall when you first visit 127.0.0.1:8000

  • Before you can use docker exec -it chevereto bash into container /var/www/html

  • no permission write phots to /home/xxx/images,you can use chmod -R 777 /home/xxx/images

  • no permission update chevereto from 1.1.4 to1.2.2 ,no update possible: /app/install/update/temp/ path,that is no temp folder in /app/install/update/ under version 1.2.0,you can mkdir temp and then chmod -R 777 ./temp and then refresh the webpage ,the prics bed will update successfully

So , you can use ip address to visit your chevereto . However , we usually use domain name such as example.com to visit web, a https isn ecessary as well

  • 1.Use aliyun to apply a free ssl license for a domain name such as pics.example.com
  • 2.Download pem and keys to your server and put it in nginx conf folder
  • 3.Use the conf as follows
   server {
        listen 80;
        server_name  pics.example.com;
        return 301 https://pics.example.com$request_uri;
    }

    server {
        listen 443 ssl;
        server_name  pics.example.com;
        gzip on;    

        ssl_certificate cert/xxxxxx9_pics.example.com.pem; # pem's filename
        ssl_certificate_key cert/xxxxxx9_pics.example.com.key;# key's filename

        location / {
            proxy_redirect off;
            proxy_pass http://dockername;

            proxy_set_header  Host                $http_host;
            proxy_set_header  X-Real-IP           $remote_addr;
            proxy_set_header  X-Forwarded-Ssl     on;
            proxy_set_header  X-Forwarded-For     $proxy_add_x_forwarded_for;
            proxy_set_header  X-Forwarded-Proto   $scheme;
            proxy_set_header  X-Frame-Options     SAMEORIGIN;

            client_max_body_size        100m;
            client_body_buffer_size     128k;

            proxy_buffer_size           4k;
            proxy_buffers               4 32k;
            proxy_busy_buffers_size     64k;
            proxy_temp_file_write_size  64k;
        }
    }
    1. And then you can visit https://pics.example.com

That‘s my story that building pics bed ,and hope to help you.

thanks

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值