Where is My Environment Variables? Journey to Linux Service

Ok, I had a .NET Core Web App running in Ubuntu behind Nginx. Everything else is fine except I can't retrieve the value of the environment variables that I put in /etc/environment.

After hours of googling, turns out systemd service strips all out except some variables. Two ways to fix this:

1. Put the environment variable in the .service config file

[Service]
Environment=MY_ENV_VAR=thevalue

2. Include /etc/environment in the service. (I don't think this is a good idea, especially for my use case).

[Service]
EnvironmentFile=/etc/environment


Comments

Popular posts from this blog

AWS EC2 Can't Reach EC2 Metadata Service After Subnet Change

A2 Hosting with .NET Core 2.1

Xcode CodeSign Incorrectly States Password is Incorrect