Skip to content

Instantly share code, notes, and snippets.

@bendo01
Last active December 6, 2024 10:54
Show Gist options
  • Save bendo01/72c08783ccec7e63a395a6f1cc9cc9f3 to your computer and use it in GitHub Desktop.
Save bendo01/72c08783ccec7e63a395a6f1cc9cc9f3 to your computer and use it in GitHub Desktop.

Revisions

  1. bendo01 revised this gist Apr 20, 2017. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion command.txt
    Original file line number Diff line number Diff line change
    @@ -7,4 +7,5 @@
    #https://lecturesnippets.com/lesson/protecting-centos-7-minimal-with-fail2ban/
    https://briansnelson.com/How_to_install_gifsicle_for_CentOS
    https://briansnelson.com/How_to_install_jpegoptim_for_CentOS
    http://linuxcommando.blogspot.co.id/2014/09/how-to-optimize-png-images.html
    http://linuxcommando.blogspot.co.id/2014/09/how-to-optimize-png-images.html
    https://blog.harrier.us/running-caddy-as-a-reverse-proxy-on-centos-7/
  2. bendo01 revised this gist Apr 20, 2017. 2 changed files with 2 additions and 0 deletions.
    1 change: 1 addition & 0 deletions Caddyfile
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    #cd /etc/caddy/Caddyfile
    example.com {
    root /usr/share/nginx/html
    gzip
    1 change: 1 addition & 0 deletions caddy.service
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    #sudo nano /etc/systemd/system/caddy.service
    [Unit]
    Description=Caddy HTTP/2 web server
    Documentation=https://caddyserver.com/docs
  3. bendo01 revised this gist Feb 7, 2017. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion command.txt
    Original file line number Diff line number Diff line change
    @@ -4,4 +4,7 @@
    #http://vicendominguez.blogspot.co.id/2015/02/supervisord-in-centos-7-systemd-version.html
    #http://stackoverflow.com/questions/31157928/supervisord-on-linux-centos-7-only-works-when-run-with-root
    #https://binaryfigments.com/news/limit-requests-on-caddy-with-fail2ban/
    #https://lecturesnippets.com/lesson/protecting-centos-7-minimal-with-fail2ban/
    #https://lecturesnippets.com/lesson/protecting-centos-7-minimal-with-fail2ban/
    https://briansnelson.com/How_to_install_gifsicle_for_CentOS
    https://briansnelson.com/How_to_install_jpegoptim_for_CentOS
    http://linuxcommando.blogspot.co.id/2014/09/how-to-optimize-png-images.html
  4. bendo01 revised this gist Oct 23, 2016. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion command.txt
    Original file line number Diff line number Diff line change
    @@ -2,4 +2,6 @@
    #download caddy web server and put file on /usr/local/bin
    #create caddy config file aka Caddyfile on /etc/caddy
    #http://vicendominguez.blogspot.co.id/2015/02/supervisord-in-centos-7-systemd-version.html
    #http://stackoverflow.com/questions/31157928/supervisord-on-linux-centos-7-only-works-when-run-with-root
    #http://stackoverflow.com/questions/31157928/supervisord-on-linux-centos-7-only-works-when-run-with-root
    #https://binaryfigments.com/news/limit-requests-on-caddy-with-fail2ban/
    #https://lecturesnippets.com/lesson/protecting-centos-7-minimal-with-fail2ban/
  5. bendo01 revised this gist Oct 22, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion command.txt
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    #login as root
    #download caddy web server and put file on /usr/local/bin
    #create caddy config file aka Caddyfile on /etc/
    #create caddy config file aka Caddyfile on /etc/caddy
    #http://vicendominguez.blogspot.co.id/2015/02/supervisord-in-centos-7-systemd-version.html
    #http://stackoverflow.com/questions/31157928/supervisord-on-linux-centos-7-only-works-when-run-with-root
  6. bendo01 revised this gist Oct 19, 2016. 1 changed file with 3 additions and 14 deletions.
    17 changes: 3 additions & 14 deletions command.txt
    Original file line number Diff line number Diff line change
    @@ -1,16 +1,5 @@
    #login as root
    #download caddy web server and put file on /usr/local/bin
    #create caddy config file aka Caddyfile on /etc/caddy
    #create non login user
    sudo adduser caddy -s /sbin/nologin
    #create dir /var/log/caddy
    mkdir /var/log/caddy
    #create file caddy.servce on /etc/systemd/system

    #resource
    https://scottlinux.com/2014/12/08/how-to-create-a-systemd-service-in-linux-centos-7/
    https://github.com/mholt/caddy/issues/1104
    https://novelist.xyz/tech/caddy-webserver/

    #To allow non-root user to bind to port 80 and 443, run the following command in your terminal
    sudo setcap cap_net_bind_service=+ep /path-to/caddy
    #create caddy config file aka Caddyfile on /etc/
    #http://vicendominguez.blogspot.co.id/2015/02/supervisord-in-centos-7-systemd-version.html
    #http://stackoverflow.com/questions/31157928/supervisord-on-linux-centos-7-only-works-when-run-with-root
  7. bendo01 revised this gist Oct 9, 2016. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion command.txt
    Original file line number Diff line number Diff line change
    @@ -9,4 +9,8 @@ mkdir /var/log/caddy

    #resource
    https://scottlinux.com/2014/12/08/how-to-create-a-systemd-service-in-linux-centos-7/
    https://github.com/mholt/caddy/issues/1104
    https://github.com/mholt/caddy/issues/1104
    https://novelist.xyz/tech/caddy-webserver/

    #To allow non-root user to bind to port 80 and 443, run the following command in your terminal
    sudo setcap cap_net_bind_service=+ep /path-to/caddy
  8. bendo01 revised this gist Oct 9, 2016. 1 changed file with 9 additions and 1 deletion.
    10 changes: 9 additions & 1 deletion Caddyfile
    Original file line number Diff line number Diff line change
    @@ -2,6 +2,14 @@ example.com {
    root /usr/share/nginx/html
    gzip
    log /var/log/caddy/access.log
    fastcgi / unix:/var/run/php-fpm/php-fpm.sock php # Fast CGI php interpreter
    #fastcgi / unix:/var/run/php-fpm/php-fpm.sock php # Fast CGI php interpreter
    #fastcgi / fastcgi / 127.0.0.1:9000 php # Fast CGI php interpreter
    #using with laravel
    fastcgi / unix:/var/run/php-fpm/php-fpm.sock php {
    index index.php
    }

    rewrite {
    to {path} {path}/ /index.php?{query}
    }
    }
  9. bendo01 created this gist Oct 9, 2016.
    7 changes: 7 additions & 0 deletions Caddyfile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    example.com {
    root /usr/share/nginx/html
    gzip
    log /var/log/caddy/access.log
    fastcgi / unix:/var/run/php-fpm/php-fpm.sock php # Fast CGI php interpreter
    #fastcgi / fastcgi / 127.0.0.1:9000 php # Fast CGI php interpreter
    }
    50 changes: 50 additions & 0 deletions caddy.service
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,50 @@
    [Unit]
    Description=Caddy HTTP/2 web server
    Documentation=https://caddyserver.com/docs
    After=network-online.target
    Wants=network-online.target systemd-networkd-wait-online.service

    [Service]
    Restart=on-failure

    ; User and group the process will run as.
    User=root
    Group=root

    ; Letsencrypt-issued certificates will be written to this directory.
    ;Environment=HOME=/etc/ssl/caddy

    ; Always set "-root" to something safe in case it gets forgotten in the Caddyfile.
    ExecStart=/usr/local/bin/caddy -log stdout -agree=true -conf=/etc/caddy/Caddyfile -root=/var/tmp
    ExecReload=/bin/kill -USR1 $MAINPID

    ; Limit the number of file descriptors; see `man systemd.exec` for more limit settings.
    LimitNOFILE=1048576
    ; Unmodified caddy is not expected to use more than that.
    LimitNPROC=64

    ; Use private /tmp and /var/tmp, which are discarded after caddy stops.
    PrivateTmp=true
    ; Use a minimal /dev
    ;PrivateDevices=true
    ; Hide /home, /root, and /run/user. Nobody will steal your SSH-keys.
    ;ProtectHome=true
    ; Make /usr, /boot, /etc and possibly some more folders read-only.
    ;ProtectSystem=full
    ; … except /etc/ssl/caddy, because we want Letsencrypt-certificates there.
    ; This merely retains r/w access rights, it does not add any new. Must still be writable on the host!
    ;ReadWriteDirectories=/etc/ssl/caddy

    ; Drop all other capabilities. Important if you run caddy as privileged user (which you should not).
    ;CapabilityBoundingSet=CAP_NET_BIND_SERVICE
    ; … but permit caddy to open ports reserved for system services.
    ; This could be redundant here, but is needed in case caddy runs as nobody:nogroup.
    ;AmbientCapabilities=CAP_NET_BIND_SERVICE
    ; … and prevent gaining any new privileges.
    ;NoNewPrivileges=true

    ; Caveat: Some plugins need additional capabilities. Add them to both above lines.
    ; - plugin "upload" needs: CAP_LEASE

    [Install]
    WantedBy=multi-user.target
    12 changes: 12 additions & 0 deletions command.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    #login as root
    #download caddy web server and put file on /usr/local/bin
    #create caddy config file aka Caddyfile on /etc/caddy
    #create non login user
    sudo adduser caddy -s /sbin/nologin
    #create dir /var/log/caddy
    mkdir /var/log/caddy
    #create file caddy.servce on /etc/systemd/system

    #resource
    https://scottlinux.com/2014/12/08/how-to-create-a-systemd-service-in-linux-centos-7/
    https://github.com/mholt/caddy/issues/1104