Skip to content

Commit

Permalink
Use port 80 by default
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed May 16, 2024
1 parent 066d480 commit 0981bab
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions rust/WEB-SERVER.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ $ sudo ./target/debug/agama-web-server serve

If it fails to compile, please check whether `clang-devel` and `pam-devel` are installed.

By default the server uses port 3000 and listens on all network interfaces. You
By default the server uses port 80 and listens on all network interfaces. You
can use the `--address` option if you want to use a different port or a specific
network interface:

Expand All @@ -76,7 +76,7 @@ option for that.
You can check whether the server is up and running by just performing a ping:

```
$ curl http://localhost:3000/ping
$ curl http://localhost/ping
```

### Authentication
Expand All @@ -85,7 +85,7 @@ The web server uses a bearer token for HTTP authentication. You can get the toke
password to the `/auth` endpoint.

```
$ curl http://localhost:3000/api/auth \
$ curl http://localhost/api/auth \
-H "Content-Type: application/json" \
-d '{"password": "your-password"}'
{"token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE3MDg1MTA5MzB9.3HmKAC5u4H_FigMqEa9e74OFAq40UldjlaExrOGqE0U"}⏎
Expand All @@ -94,7 +94,7 @@ $ curl http://localhost:3000/api/auth \
Now you can access protected routes by including the token in the header:

```
$ curl -X GET http://localhost:3000/protected \
$ curl -X GET http://localhost/protected \
-H "Accept: application/json" \
-H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE3MDg1MTA5MzB9.3HmKAC5u4H_FigMqEa9e74OFAq40UldjlaExrOGqE0U"
```
Expand All @@ -116,7 +116,7 @@ $ cargo install websocat
Now, you can use the following command to connect:

```
$ websocat ws://localhost:3000/ws
$ websocat ws://localhost/ws
-H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE3MDg1MTA5MzB9.3HmKAC5u4H_FigMqEa9e74OFAq40UldjlaExrOGqE0U"
```

Expand Down
2 changes: 1 addition & 1 deletion rust/agama-cli/src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::path::{Path, PathBuf};

const DEFAULT_JWT_FILE: &str = ".agama/agama-jwt";
const DEFAULT_AGAMA_TOKEN_FILE: &str = "/run/agama/token";
const DEFAULT_AUTH_URL: &str = "http://localhost:3000/api/auth";
const DEFAULT_AUTH_URL: &str = "http://localhost/api/auth";
const DEFAULT_FILE_MODE: u32 = 0o600;

#[derive(Subcommand, Debug)]
Expand Down
2 changes: 1 addition & 1 deletion rust/agama-lib/src/network/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::error::ServiceError;
use reqwest::{Client, Response};
use serde_json;

const API_URL: &str = "http://localhost:3000/api/network";
const API_URL: &str = "http://localhost/api/network";

/// HTTP/JSON client for the network service
pub struct NetworkClient {
Expand Down
4 changes: 2 additions & 2 deletions rust/agama-server/src/agama-web-server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ fn find_web_ui_dir() -> PathBuf {

#[derive(Args, Debug)]
struct ServeArgs {
// Address/port to listen on (":::3000" listens for both IPv6 and IPv4
// Address/port to listen on (":::80" listens for both IPv6 and IPv4
// connections unless manually disabled in /proc/sys/net/ipv6/bindv6only)
#[arg(long, default_value = ":::3000", help = "Primary address to listen on")]
#[arg(long, default_value = ":::80", help = "Primary address to listen on")]
address: String,
#[arg(
long,
Expand Down

0 comments on commit 0981bab

Please sign in to comment.