Comments (20)
Hi @coltonbh,
After some hours, it worked doing the following:
1- To create user:password pair, it's possible to use this command:
echo $(htpasswd -nb user password) | sed -e s/\\$/\\$\\$/g
2- Add quotes in this line:
-"traefik.http.middlewares.testauth.basicauth.users=example:$$apr1$$BVhy2emr$$PRkqFeoHHQbIQtE5McvOc0"
Thanks to point out this issue.
from dockerswarm.rocks.
And of course after painstakingly figuring out all these details, then reproducing it from the start the above seems incorrect! The ${VARIABLE?Variable not set}
notation seems to work just fine. I think I somehow failed to correctly set my environment variables thereby creating the initial error?? 🤦🏼♂️
However, the note about export USERNAME=admin
not changing the $USERNAME
on ubuntu
may be worth adding--I think that was at the root of all the bizarre paths I went down trying to debug.
from dockerswarm.rocks.
I believe you may need to add an additional $
to your credentials if placed directly in the file, you also want to remove the double quotes from your password--those are being included.
So try:
`❯ htpasswd -nb example password
example:$apr1$BVhy2emr$PRkqFeoHHQbIQtE5McvOc0`
Then place the following in your yaml file:
example:$$apr1$$BVhy2emr$$PRkqFeoHHQbIQtE5McvOc0
Any luck?
from dockerswarm.rocks.
@kaleming congrats! I figured it was something small like that. Nice sleuthing.
from dockerswarm.rocks.
My problem was caused because of sudo
For docker usage, I used the command with sudo so enivornment variables not shared.
In this case, just share current environments using -E
argument
sudo docker -E stack deploy ...
from dockerswarm.rocks.
I got the same error.
I followed your steps and it solved the first issue. However I still can't log in (401 Unauthorized).
I have tried using my user and password without success.
Which password did work for you (with ubuntu username) ?
from dockerswarm.rocks.
The password set in the $PASSWORD variable did work for me once I used the ubuntu
username instead of what I had set in $USERNAME.
from dockerswarm.rocks.
In my case, it doesn't work using the password I set in the $PASSWORD. How did you find out ubuntu
as $USERNAME ?
from dockerswarm.rocks.
echo $USERNAME
is always ubuntu
regardless what I set using export USERNAME=my_own_name
from dockerswarm.rocks.
In my case both echo $USERNAME
and echo $PASSWORD
seems correct, but I still get:
"GET / HTTP/2.0" 401
I have tried to write the credetials directly on yml file:
traefik.http.middlewares.admin-auth.basicauth.users=example:password
I have also tried placing hash instead: example:$apr1$nyeKGV3t$Qj1EEOqrS1wKoURU6CPCU/
generated using htpasswd -nb example "password"
But no success either.
from dockerswarm.rocks.
Unfortunately I still get the same - 401 Unauthorized message.
from dockerswarm.rocks.
You know what, @kaleming I set up a new swarm yesterday and had the exact same issue again--traefik always gave me 401 responses with the variable defined USERNAME
and PASSWORD
so I had to do exactly what you did with the "" and the hard coded line. Not sure why this is...
from dockerswarm.rocks.
Hi @coltonbh, I'm glad this approach worked for you too.
I didn't have time to go further into this issue, I am not sure why either.
from dockerswarm.rocks.
Yeah I'm curious what the issue with using the environment variables in the main example. I can't figure it out...
from dockerswarm.rocks.
Are you setting the $HASHED_PASSWORD
As specified here?
export HASHED_PASSWORD=$(openssl passwd -apr1 $PASSWORD)
(Optional): Alternatively, if you don't want to put the password in an environment variable, you could type it interactively, e.g.:
$ export HASHED_PASSWORD=$(openssl passwd -apr1)
Password: $ enter your password here
Verifying - Password: $ re enter your password here
from dockerswarm.rocks.
Using @coltonbh suggestion:
So I changed the ${HASHED_PASSWORD?Variable not set} and other related values containing the ?Variable not set addendum to ${HASHED_PASSWORD}.
Works like a charm in my case.
I do not really understand if the problem is related to the template file or to a bug in docker-compose (it is documented here).
I share my current environment:
- Ubuntu 18.04.5 LTS
- Docker version 19.03.11, build dd360c7 (snap version)
from dockerswarm.rocks.
Try changing the template from $ to $$ (Ubuntu 20.04)
from dockerswarm.rocks.
I had this issue on Windows. I thought it was a problem with variable expansion as well, but I was wrong. I set a few env variables the .toml was looking for and it fixed the issue.
For some reason the .env file isn't being picked up or used. Therefore, all env variables were empty.
I made a quick gist to turn the .env file into 'set name=value' notation windows wants.
I pasted the output in the terminal and everything worked. Attaching gist below.
# run in dir with a .env file. prints text block to paste into cmd to load env variables
import os
import re
with open('.env', 'r', encoding='utf-8') as fs:
env_vars = fs.read().splitlines()
good_pairs = []
[good_pairs.append(f'set {var_pair}') for var_pair in env_vars if not re.findall('^ ?#', var_pair) and var_pair != '']
# [os.system(f'set {var_pair}') for var_pair in env_vars if not re.findall('^ ?#', var_pair) and var_pair != '']
print(good_pairs)
for pair in good_pairs:
print(pair)
# os.system(pair)
from dockerswarm.rocks.
Thanks for the patience! And thanks for the notes. Maybe if someone wants to update the examples to use something different than USERNAME
I would take that PR.
Nevertheless, I should let you know, I had to deprecate this website and ideas, I would no longer recommend Docker Swarm Mode for new projects: https://dockerswarm.rocks/swarm-or-kubernetes/ 🥲
from dockerswarm.rocks.
Assuming the original issue was solved, it will be automatically closed now. But feel free to add more comments or create new issues.
from dockerswarm.rocks.
Related Issues (20)
- Swarmpit setup fails - http://db:5984 host unreachable HOT 4
- Service placement on different node makes it unreachable HOT 2
- Swarmpit on ARM HOT 1
- Let's encrypt issue HOT 2
- Setting up hostname didn't work
- 404 for grafana / prometheus requests HOT 2
- Traefik example and its labels HOT 1
- Suggestion: Start with simple stack to get Portainer running with Caddy HOT 2
- Traefik on 2 Manager Nodes HOT 4
- What are the things to look when traefik.<domain name> is not loading? HOT 2
- Any recommended FOSS projects for Docker Swarm Mode deployments? HOT 3
- Traefik : redirect all http to https HOT 4
- n/a
- nginx loadbalancer
- Custom SSL Certificate HOT 2
- [feature request] dark mode for dockerswarm.rocks HOT 1
- Traefik redundancy and DNS configuration HOT 3
- Feature Request: Explain the roles of Portainer and Swarmpit (better) HOT 1
- Is dockerswarm.rocks still maintained? HOT 13
- Everything depends on the first node despite being in swarm mode HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dockerswarm.rocks.