Q: How do I Read Environment Variables when using NGINX as a Proxy?

I am trying to host a DOT.NET 2.0 app on Ubuntu 16.04 with SQL Server 2017. I was able to install Ubuntu and SQL Server Successfully. I also installed NGINX to route the localhost:5000 to my port 80. I was also able to test a new mvc app that I created locally with the DOTNET command and launched it on the Server. I used the Server IP URL on another PC and was able to get to the test Dot.Net APP.

Here is where I ran into a problem. My Production App is using a SQL Server back-end to host the credentials and other data. In my Windows environment, I am able to setup IIS, record the Database and SendGrid credentials as System Environment Variables and successfully run the Application. Nevertheless, I am not successful running the same App on Linux Ubuntu.

One final test that I performed, which indicates that my app is working correctly:

I added the credentials inside my appsettings.json and successfully called them with the Configuration.GetConnectionString(“DATA”) function. However, I am not able to use the secure environment variable approach, that is: register the environment variables in /etc/environment

I even tried to transfer the ownership of the NGINX Service to www-data and still could not get to the database.

Is there a safe process to setup an application with a database and use either NGINX or Apache to use the app and SQL Server with environment variables set to the system environment file?

Thanks for the support. I ran out of ideas.

I’ve moved this to the https://community.ubuntu.com/c/support-help-requests category because this site isn’t designed to take tech support questions. Sorry. I’d recommend using one of the official support channels listed on the https://community.ubuntu.com/t/finding-help/712 page.