OS: Linux, CentOS Proxy: Apache Asp.NET Core 1.1
Problem: I got to a certain moment with my app when I decided to deploy it on the real server.
So everything worked and works perfectly fine on my local machine. I have no issues.
But when I published it and uploaded to the server it doesn't work the way I expected. And I mean specifically the database (SQLite). The app reads data from the db as it supposed to , but whenever there is await _db.SaveChangesAsync() in my code the app crashes.
I have searched all over the internet and didn't anything that would help me.
So far I have 3 different Exceptions:
SQLite Error 8: 'attempt to write a readonly database'.
I changed the permissions of the db file to 777 as well as the folder it self, doesn't help.
Got this: SQLite Error 14: 'unable to open database file'.
When I tried to add this to Configure:
app.UseForwardedHeaders(new ForwardedHeadersOptions { ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto });
got this exemption: warn: Microsoft.AspNetCore.HttpOverrides.ForwardedHeadersMiddleware[1] Parameter count mismatch between X-Forwarded-For and X-Forwarded-Proto.
Connection String is :
"DefaultConnection": "Data Source=GlobalEvent.db"
The problem was in the wrong reverse proxy settings. I couldn't find the correct solution for Apache, so I changed it to Nginx. To be honest I actually love it even more. Now everything works. Also, I created Nginx server blocks for subdomains. Everything else from above still applies.
Here is my conf file for ASP.NET Core app:
server {
listen 80;
root /var/www/subdomain.domain.com/html;
server_name subdomain.domain.com www.subdomain.domain.com;
location / {
proxy_pass http://localhost:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.