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

Templating of Server Config & Monitoring #168

Open
wants to merge 17 commits into
base: master
Choose a base branch
from

Conversation

usmcamp0811
Copy link
Contributor

@usmcamp0811 usmcamp0811 commented Aug 19, 2022

I'm still working out some bugs but I wanted to open this PR to make you aware of my modifications. I wanted to be able to modify some of the server configs a little easier and so I modified it to be more like a template. Instead of copying the server.conf to /etc/openvpn at build time, I am doing it as part of the start.sh. I created variables that have defaults of the original values, and modified the docker-compose.yml to demo some of them.

Additionally I ran across this project and thought it to be very useful and a simple thing to add to the docker-compose.yml.

If you want me to break these two things out into seperate PRs I can.

I also thought about using something like cookie to template the server.conf but you're using an alpine image and I didn't really want to muck around trying to get it installed bloating the image more than was actually needed. Instead I just went with a simple eval method that will inject variables into the server.conf

I dunno..... thoughts?

@alekslitvinenk
Copy link
Collaborator

Hi Matt,

Thanks a lot for your generous contribution! I'll review ASAP

@usmcamp0811
Copy link
Contributor Author

Ok so I changed my mind.. the eval method I was trying just wasn't working out so I opted to use Cookiecutter. Pretty sure I got everything working as it should. Let me know if you have any questions.

@alekslitvinenk
Copy link
Collaborator

Sure thing. Thanks a lot once again for your contribution

@usmcamp0811
Copy link
Contributor Author

No problem.. my router that I usually run my VPN on started acting up and I got to looking for a simple docker image that I could use and ran across yours... then of course I wanted to make modifications... and well one things leads to another and I might as well push them back up..

CLIENT_ID="$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)"
ARG1=$1
DEFAULT_ID="$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)"
CLIENT_ID="${ARG1:=$DEFAULT_ID}"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I more or less did what was mentioned here. I also modified how start.sh called this function.

@@ -38,10 +40,14 @@ then
fi
;;
o)
CLIENT_PATH="$(createConfig $2)"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and for all the other cases I moved the createConfig call to the cases and passed in the second/third optional argument which is mean to be the cert name. If its not passed the cert name will revert to the random name.

@usmcamp0811
Copy link
Contributor Author

The last thing I am going to probably do is add iroute / route to the config so that VPN LAN can access remote VPN Clients.

@alekslitvinenk
Copy link
Collaborator

Hi Matt, I really appreciate your commitment. Like I said I'll have a detailed look when I finalize the feature I'm currently working on. Generally speaking it's always better to raise smaller PRs for incremental improvements, but it's OK to have it as one lump too.

I'll then cover with tests here https://github.com/dockovpn/dockovpn-it

CLIENT_PATH="$APP_PERSIST_DIR/clients/$CLIENT_ID"
[ -d $CLIENT_PATH ] && CLIENT_PATH=${CLIENT_PATH}_1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if given path already exists it's better to return an error code. Otherwise, we will end up in a situation where we have two certificates with the same subject name (CLIENT_ID is present in generated certificate in subject field), which in its turn may lead to other problems. For instance, when we remove client with rmclient.sh we supply subject name as a parameter and certificate is revoked.


WORKDIR ${APP_INSTALL_PATH}

COPY scripts .
COPY config ./config
COPY VERSION ./config

RUN apk add --no-cache openvpn easy-rsa bash netcat-openbsd zip dumb-init && \
RUN apk add --no-cache python3 py-pip openvpn easy-rsa bash netcat-openbsd zip dumb-init && \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thoroughly reviewed the templating part and it's truly amazing! However it brings in another execution environment i.e python and package dependencies which leads to much greater image size. At the moment I'd like to keep resulting image as small as possible for the benefit of embedded and RISK architectures.
Screenshot 2022-09-05 at 23 22 45

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

Successfully merging this pull request may close these issues.

None yet

2 participants