Compare commits

...
2 Commits
Author SHA1 Message Date
kham 09ac6c6bb1 add nginx in arch linux style 2026-05-14 21:59:52 +10:00
kham 8228ff27b8 adding config for arch linux and nginx 2026-05-14 21:59:19 +10:00
5 changed files with 153 additions and 23 deletions
+9 -8
View File
@@ -22,19 +22,20 @@ services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
services.AddEndpointsApiExplorer(); services.AddEndpointsApiExplorer();
services.AddSwaggerGen(); services.AddSwaggerGen();
string skey = "Super Secret SIGN AND VERIFY JWT TOKENS";
var appSettingsSection = builder.Configuration.GetSection("AppSettings"); var appSettingsSection = builder.Configuration.GetSection("AppSettings");
string skey = ""; if (appSettingsSection != null)
if (appSettingsSection == null)
{
skey = builder.Configuration.GetValue<string>("AppSettings:SecretKey");
}
else
{ {
services.Configure<AppSettings>(appSettingsSection); services.Configure<AppSettings>(appSettingsSection);
var appSettings = appSettingsSection.Get<AppSettings>(); var appSettings = appSettingsSection.Get<AppSettings>();
skey = appSettings.Secret; if ( appSettings != null)
skey = appSettings.Secret;
else
{
skey = builder.Configuration.GetValue<string>("AppSettings:Secret");
}
} }
var key = Encoding.ASCII.GetBytes(skey); var key = Encoding.ASCII.GetBytes(skey);
services.AddAuthentication(x => services.AddAuthentication(x =>
+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"AppSettings": { "AppSettings": {
"Secret": "Nepean Blue Mountain Super Secret SIGN AND VERIFY JWT TOKENS, BEARER TOKEN USE WHEN CALLING THIS API.", "Secret": "Super Secret SIGN AND VERIFY JWT TOKENS, BEARER TOKEN USE WHEN CALLING THIS API.",
"SQLConnectionString": "host=localhost;port=5432;database=FamilyTreeDB;username=postgres;password=Positive~1;", "SQLConnectionString": "host=localhost;port=5432;database=FamilyTreeDB;username=postgres;password=Positive~1;",
"SQLConnectionString_vm": "host=192.168.1.240;port=5432;database=FamilyTreeDB;username=postgres;password=Positive~1;", "SQLConnectionString_vm": "host=192.168.1.240;port=5432;database=FamilyTreeDB;username=postgres;password=Positive~1;",
+7 -5
View File
@@ -1,15 +1,17 @@
[Unit] [Unit]
Description=ASP.NET Core Web App running on Ubuntu Description=ASP.NET Core Web App running on arch linux
[Service] [Service]
WorkingDirectory=/var/www/familytree/api WorkingDirectory=/var/www/familytree/api
ExecStart=/usr/bin/dotnet /var/www/familytree/api/FamilyTreeAPI.dll ExecStart=/usr/bin/dotnet /var/www/familytree/api/FamilyTreeAPI.dll
Restart=always Restart=always
# Restart service after 10 seconds if the dotnet service crashes: # Restart service after 20 seconds if the dotnet service crashes:
RestartSec=10 RestartSec=20
KillSignal=SIGINT KillSignal=SIGINT
SyslogIdentifier=dotnet-web-familytree-api SyslogIdentifier=dotnet-web-familytree-api
# This user should exist on the server and have ownership of the deployment directory # This user should exist on the server and have ownership of the deployment directory
User=www-data #User=www-data this is other ubuntu
#arch linux has user http
User=http
Environment=ASPNETCORE_ENVIRONMENT=Production Environment=ASPNETCORE_ENVIRONMENT=Production
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target
+13 -9
View File
@@ -2,8 +2,9 @@
#make sure in nginx.conf has include module.d/*.conf inside http block one. #make sure in nginx.conf has include module.d/*.conf inside http block one.
server { server {
listen 80; #make nginx out side listen 82; listen 80; #make nginx out side listen 82;
location / { location /familytreeapi/ {
proxy_pass http://127.0.0.1:5000; #proxy_pass http://127.0.0.1:5015;
proxy_pass http://192.168.1.219:5015/;
proxy_http_version 1.1; proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade; proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive; proxy_set_header Connection keep-alive;
@@ -13,20 +14,23 @@
proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Proto $scheme;
} }
location /familytreeui {
return 301 /familytreeui/; #if same one redirect to /familytreeui/
}
location /familytreeui/ { location /familytreeui/ {
root /var/www/familytree; #path must exist like /var/www/familytree/familytreeui and /var/www/familytree/api folder. root /var/www/familytree/; #path must exist like /var/www/familytree/familytreeui and /var/www/familytree/api folder.
index index.html #index index.html;
try_files $uri $uri/ /index.html; try_files $uri $uri/ /index.html;
} }
# Optional: Cache static assets for better performance # Optional: Cache static assets for better performance
location ~* \.(?:ico|css|js|gif|jpe?g|png)$ { #location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
expires 30d; # expires 30d;
add_header Cache-Control "public"; # add_header Cache-Control "public";
} #}
error_page 404 /index.html; # error_page 404 /index.html;
# put in /etc/nginx/sites-availalble/familytreeapp.conf # put in /etc/nginx/sites-availalble/familytreeapp.conf
# link to enable # link to enable
+123
View File
@@ -0,0 +1,123 @@
user http;
worker_processes auto;
worker_cpu_affinity auto;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
# Load all installed modules
#include modules.d/*.conf;
events {
worker_connections 1024;
}
http {
charset utf-8;
include mime.types;
default_type application/octet-stream;
types_hash_max_size 4096;
client_max_body_size 16M;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
include modules.d/*.conf;
server {
listen 81;
server_name localhost;
#access_log logs/host.access.log main;
#kham comment out first
#location / {
# root /usr/share/nginx/html;
# index index.html index.htm;
# }
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}