fachinformatiker-wiki

it's easy when it's here

User Tools

Site Tools


linux:webhosting

Webhosting Commands

sudo chown -R www-data:www-data /var/www/html*
sudo find /var/www/html/ -type d -exec chmod 775 {} \;
sudo find /var/www/html/ -type f -exec chmod 664 {} \;
sudo find /var/www/html -type d -exec chmod g+s {} \;
sudo systemctl restart nginx

htpasswd

Generate Basic Auth Credentials

Installation

sudo apt update
sudp apt install htpasswd

Generate Credentials

htpasswd -n werner                                # generate cerdentials for user "werner" and display the results 
                                                  # on standard output rather than updating a file
htpasswd -c ~/public_html/.htpasswd werner        # generate ".htpasswd" file and create credentials for user "werner"
htpasswd ~/public_html/.htpasswd werner           # create or modify credentials for user "werner" in ".htpasswd" file

Traefik

Don't forget to escape dollar signs ($ → $$) in traefik docker compose files!

use this command:

echo $(htpasswd -nB werner) | sed -e s/\\$/\\$\\$/g

in the docker compose file:

...
    labels:
      - "traefik.enable=true"
      - "traefik.docker.network=traefik-prod"
      - "traefik.http.services.nginx-web-prod.loadbalancer.server.port=8180"
      - "traefik.http.routers.nginx-web-prod.middlewares=basicauth-prod"
      - "traefik.http.middlewares.basicauth-prod.basicauth.users=werner:$$apr1$$3FS0FG.s$$rc0h/7C36ABYDS45XKEQ."
...
This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.  More information about cookies 
linux/webhosting.txt · Last modified: 2024/02/17 19:03 by 127.0.0.1