mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-31 04:23:40 +00:00
minor fixes, add nginx conf
This commit is contained in:
committed by
Aiden McClelland
parent
1059ccfc96
commit
84916ad9d5
104
appmgr/nginx.conf
Normal file
104
appmgr/nginx.conf
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
##
|
||||||
|
# You should look at the following URL's in order to grasp a solid understanding
|
||||||
|
# of Nginx configuration files in order to fully unleash the power of Nginx.
|
||||||
|
# https://www.nginx.com/resources/wiki/start/
|
||||||
|
# https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/
|
||||||
|
# https://wiki.debian.org/Nginx/DirectoryStructure
|
||||||
|
#
|
||||||
|
# In most cases, administrators will remove this file from sites-enabled/ and
|
||||||
|
# leave it as reference inside of sites-available where it will continue to be
|
||||||
|
# updated by the nginx packaging team.
|
||||||
|
#
|
||||||
|
# This file will automatically load configuration files provided by other
|
||||||
|
# applications, such as Drupal or Wordpress. These applications will be made
|
||||||
|
# available underneath a path with that package name, such as /drupal8.
|
||||||
|
#
|
||||||
|
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
|
||||||
|
##
|
||||||
|
|
||||||
|
# Default server configuration
|
||||||
|
#
|
||||||
|
server {
|
||||||
|
listen 80 default_server;
|
||||||
|
listen [::]:80 default_server;
|
||||||
|
|
||||||
|
# SSL configuration
|
||||||
|
#
|
||||||
|
# listen 443 ssl default_server;
|
||||||
|
# listen [::]:443 ssl default_server;
|
||||||
|
#
|
||||||
|
# Note: You should disable gzip for SSL traffic.
|
||||||
|
# See: https://bugs.debian.org/773332
|
||||||
|
#
|
||||||
|
# Read up on ssl_ciphers to ensure a secure configuration.
|
||||||
|
# See: https://bugs.debian.org/765782
|
||||||
|
#
|
||||||
|
# Self signed certs generated by the ssl-cert package
|
||||||
|
# Don't use them in a production server!
|
||||||
|
#
|
||||||
|
# include snippets/snakeoil.conf;
|
||||||
|
|
||||||
|
root /var/www/html;
|
||||||
|
|
||||||
|
# Add index.php to the list if you are using PHP
|
||||||
|
index index.html index.htm index.nginx-debian.html;
|
||||||
|
|
||||||
|
server_name _;
|
||||||
|
|
||||||
|
proxy_request_buffering off;
|
||||||
|
|
||||||
|
location /rpc {
|
||||||
|
proxy_pass http://localhost:5959/;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /ws/ {
|
||||||
|
proxy_pass http://localhost:5960/;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection "Upgrade";
|
||||||
|
}
|
||||||
|
|
||||||
|
location / {
|
||||||
|
# First attempt to serve request as file, then
|
||||||
|
# as directory, then fall back to displaying a 404.
|
||||||
|
try_files $uri $uri/ =404;
|
||||||
|
}
|
||||||
|
|
||||||
|
# pass PHP scripts to FastCGI server
|
||||||
|
#
|
||||||
|
#location ~ \.php$ {
|
||||||
|
# include snippets/fastcgi-php.conf;
|
||||||
|
#
|
||||||
|
# # With php-fpm (or other unix sockets):
|
||||||
|
# fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
|
||||||
|
# # With php-cgi (or other tcp sockets):
|
||||||
|
# fastcgi_pass 127.0.0.1:9000;
|
||||||
|
#}
|
||||||
|
|
||||||
|
# deny access to .htaccess files, if Apache's document root
|
||||||
|
# concurs with nginx's one
|
||||||
|
#
|
||||||
|
#location ~ /\.ht {
|
||||||
|
# deny all;
|
||||||
|
#}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Virtual Host configuration for example.com
|
||||||
|
#
|
||||||
|
# You can move that to a different file under sites-available/ and symlink that
|
||||||
|
# to sites-enabled/ to enable it.
|
||||||
|
#
|
||||||
|
#server {
|
||||||
|
# listen 80;
|
||||||
|
# listen [::]:80;
|
||||||
|
#
|
||||||
|
# server_name example.com;
|
||||||
|
#
|
||||||
|
# root /var/www/example.com;
|
||||||
|
# index index.html;
|
||||||
|
#
|
||||||
|
# location / {
|
||||||
|
# try_files $uri $uri/ =404;
|
||||||
|
# }
|
||||||
|
#}
|
||||||
@@ -11,7 +11,7 @@ use rpc_toolkit::command;
|
|||||||
use rpc_toolkit::hyper::upgrade::Upgraded;
|
use rpc_toolkit::hyper::upgrade::Upgraded;
|
||||||
use rpc_toolkit::hyper::{Body, Error as HyperError, Request, Response};
|
use rpc_toolkit::hyper::{Body, Error as HyperError, Request, Response};
|
||||||
use rpc_toolkit::yajrc::RpcError;
|
use rpc_toolkit::yajrc::RpcError;
|
||||||
use serde::Serialize;
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use tokio::task::JoinError;
|
use tokio::task::JoinError;
|
||||||
use tokio_tungstenite::tungstenite::Message;
|
use tokio_tungstenite::tungstenite::Message;
|
||||||
@@ -19,7 +19,8 @@ use tokio_tungstenite::WebSocketStream;
|
|||||||
|
|
||||||
pub use self::model::DatabaseModel;
|
pub use self::model::DatabaseModel;
|
||||||
use self::util::WithRevision;
|
use self::util::WithRevision;
|
||||||
use crate::context::RpcContext;
|
use crate::context::{EitherContext, RpcContext};
|
||||||
|
use crate::util::{display_serializable, IoFormat};
|
||||||
use crate::{Error, ResultExt};
|
use crate::{Error, ResultExt};
|
||||||
|
|
||||||
async fn ws_handler<
|
async fn ws_handler<
|
||||||
@@ -67,24 +68,28 @@ pub async fn subscribe(ctx: RpcContext, req: Request<Body>) -> Result<Response<B
|
|||||||
Ok(res)
|
Ok(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[command(subcommands(revisions, dump, put, patch))]
|
#[command(subcommands(revisions, dump, put))]
|
||||||
pub fn db(#[context] ctx: RpcContext) -> Result<RpcContext, RpcError> {
|
pub fn db(#[context] ctx: EitherContext) -> Result<EitherContext, RpcError> {
|
||||||
Ok(ctx)
|
Ok(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Deserialize, Serialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum RevisionsRes {
|
pub enum RevisionsRes {
|
||||||
Revisions(Vec<Arc<Revision>>),
|
Revisions(Vec<Arc<Revision>>),
|
||||||
Dump(Dump),
|
Dump(Dump),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[command(rpc_only)]
|
#[command(display(display_serializable))]
|
||||||
pub async fn revisions(
|
pub async fn revisions(
|
||||||
#[context] ctx: RpcContext,
|
#[context] ctx: EitherContext,
|
||||||
#[arg] since: u64,
|
#[arg] since: u64,
|
||||||
|
#[allow(unused_variables)]
|
||||||
|
#[arg(long = "format")]
|
||||||
|
format: Option<IoFormat>,
|
||||||
) -> Result<RevisionsRes, RpcError> {
|
) -> Result<RevisionsRes, RpcError> {
|
||||||
let cache = ctx.revision_cache.read().await;
|
let rpc_ctx = ctx.as_rpc().unwrap();
|
||||||
|
let cache = rpc_ctx.revision_cache.read().await;
|
||||||
if cache
|
if cache
|
||||||
.front()
|
.front()
|
||||||
.map(|rev| rev.id <= since + 1)
|
.map(|rev| rev.id <= since + 1)
|
||||||
@@ -99,40 +104,37 @@ pub async fn revisions(
|
|||||||
))
|
))
|
||||||
} else {
|
} else {
|
||||||
drop(cache);
|
drop(cache);
|
||||||
Ok(RevisionsRes::Dump(ctx.db.dump().await))
|
Ok(RevisionsRes::Dump(rpc_ctx.db.dump().await))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[command(rpc_only)]
|
#[command(display(display_serializable))]
|
||||||
pub async fn dump(#[context] ctx: RpcContext) -> Result<Dump, RpcError> {
|
pub async fn dump(
|
||||||
Ok(ctx.db.dump().await)
|
#[context] ctx: EitherContext,
|
||||||
|
#[allow(unused_variables)]
|
||||||
|
#[arg(long = "format")]
|
||||||
|
format: Option<IoFormat>,
|
||||||
|
) -> Result<Dump, RpcError> {
|
||||||
|
Ok(ctx.as_rpc().unwrap().db.dump().await)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[command(subcommands(ui))]
|
#[command(subcommands(ui))]
|
||||||
pub fn put(#[context] ctx: RpcContext) -> Result<RpcContext, RpcError> {
|
pub fn put(#[context] ctx: EitherContext) -> Result<EitherContext, RpcError> {
|
||||||
Ok(ctx)
|
Ok(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[command(rpc_only)]
|
#[command(display(display_serializable))]
|
||||||
pub async fn ui(
|
pub async fn ui(
|
||||||
#[context] ctx: RpcContext,
|
#[context] ctx: EitherContext,
|
||||||
#[arg] pointer: JsonPointer,
|
#[arg] pointer: JsonPointer,
|
||||||
#[arg] value: Value,
|
#[arg] value: Value,
|
||||||
|
#[allow(unused_variables)]
|
||||||
|
#[arg(long = "format")]
|
||||||
|
format: Option<IoFormat>,
|
||||||
) -> Result<WithRevision<()>, RpcError> {
|
) -> Result<WithRevision<()>, RpcError> {
|
||||||
let ptr = "/ui".parse::<JsonPointer>()? + &pointer;
|
let ptr = "/ui".parse::<JsonPointer>()? + &pointer;
|
||||||
Ok(WithRevision {
|
Ok(WithRevision {
|
||||||
response: (),
|
response: (),
|
||||||
revision: ctx.db.put(&ptr, &value, None).await?,
|
revision: ctx.as_rpc().unwrap().db.put(&ptr, &value, None).await?,
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
#[command(rpc_only)]
|
|
||||||
pub async fn patch(
|
|
||||||
#[context] ctx: RpcContext,
|
|
||||||
#[arg] patch: DiffPatch,
|
|
||||||
) -> Result<WithRevision<()>, RpcError> {
|
|
||||||
Ok(WithRevision {
|
|
||||||
response: (),
|
|
||||||
revision: ctx.db.apply(patch, None, None).await?,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ pub fn echo(#[context] _ctx: EitherContext, #[arg] message: String) -> Result<St
|
|||||||
inspect::inspect,
|
inspect::inspect,
|
||||||
package,
|
package,
|
||||||
auth::auth,
|
auth::auth,
|
||||||
|
db::db,
|
||||||
))]
|
))]
|
||||||
pub fn main_api(#[context] ctx: EitherContext) -> Result<EitherContext, RpcError> {
|
pub fn main_api(#[context] ctx: EitherContext) -> Result<EitherContext, RpcError> {
|
||||||
Ok(ctx)
|
Ok(ctx)
|
||||||
|
|||||||
@@ -193,6 +193,7 @@ pub async fn check_all(ctx: &RpcContext) -> Result<(), Error> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize, HasModel)]
|
#[derive(Clone, Debug, Deserialize, Serialize, HasModel)]
|
||||||
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub struct Status {
|
pub struct Status {
|
||||||
pub configured: bool,
|
pub configured: bool,
|
||||||
pub main: MainStatus,
|
pub main: MainStatus,
|
||||||
|
|||||||
Reference in New Issue
Block a user