Anyone Docs
  • ๐Ÿ”ทThe Documentation For Anyone
    • About
    • FAQ
  • ๐Ÿ”ทRelay Setup
    • Get Started
    • Installation and Usage
      • Setting Your Environment
        • Virtualization on Windows
        • Virtualization on macOS
        • Install Ubuntu Server 22.04
        • Server management with SSH in Windows and macOS
      • Install Anon on Linux
      • Install Anon using the apt repository
      • Update Anon and accept terms and conditions
      • Install Anon in Docker
      • Configure SOCKS5 Proxy for Anyone
      • Install Anyone Exit Relay
    • Troubleshooting Common Issues
      • Diagnosing CGNAT and Public IPv4
      • Confirm ORPort Reachability
    • Firewall and Network Configurations
      • Router Port Forwarding
      • Install and Configure Firewall
    • Advanced Configuration and Troubleshooting
      • Configure IPv4 and IPv6
      • DoS mitigation parameters
    • Relay Operator Standards
    • Exit Relay Guidelines
  • ๐Ÿ”ทHardware Setup
    • Setup Guide
    • Description and Specifications
    • Relay Control Panel
      • Home
      • Network Settings
      • Relay Settings
      • Relay Family
      • Proxy Settings BETA
      • Change Password
      • Logs
      • Update
    • Update (Using USB)
    • Update to WEB 3.2.0 (Using UI)
    • Troubleshooting and additional configuration
      • Router Port Forwarding
      • Diagnosing CGNAT and Public IPv4
    • Router Setup
  • ๐Ÿ”ทSecurity and Privacy
    • VPS Hardening
  • ๐Ÿ”ทRewards Dashboard
    • Registering to the Rewards Program
    • Accessing the Rewards Dashboard
    • Using the Rewards Dashboard
    • Rewards Status
  • ๐Ÿ”ทAnyone SDK
    • NPM SDK
      • Install NPM Package
      • Run as Library
        • Anon
        • AnonSocksClient
        • AnonControlClient
      • Run from CLI
      • Tutorials
        • Hello Anon World I
        • Hello Anon World II
        • Circuit Control I
        • Circuit Control II
    • Native SDK
      • Anyone Client Releases
      • MAN - Anon Manual
      • Tutorials
        • Anyone Services I
        • Anyone Services II
    • iOS SDK [Beta]
      • Manual Install - CocoaPods
  • ๐Ÿ”ทConnect to Anyone
    • Connecting to Linux
      • [Beta] One-Click Linux Setup
    • Connecting to macOS
      • macOS with NPM
      • [Beta] One-Click macOS Setup
    • Connecting to Windows
      • [Beta] One-Click Windows Setup
    • Individual Applications with Anyone
    • Connect Through Hardware
  • ๐Ÿ”ทTokenomics
    • Introduction
    • Token Distribution
      • Token Outflow
      • Other Tokens
    • Relay Rewards
      • Lock Requirement
      • Lock Adjustments
      • Reward Multipliers
    • Additional Roles
      • Authorities and Staking
      • Governance Voting
    • Premium Circuits
      • Premium Circuits
      • Premium Circuits: Metrics
    • Summary
      • Value Accrual Summary
      • Rewards Case Study
    • Appendix
      • M Derivation
      • Risk Equation Derivation
  • ๐Ÿ”ทResources
    • Community and Customer Support
    • Links
    • Token
    • Whitepaper
    • Roadmap
    • API
      • REST
      • [Future] GraphQL
Powered by GitBook
On this page
  • Integrate SvelteKit with nginx, anon, and anyone-client
  • Set up nginx for SvelteKit
  • Configure anyone-client and anon for Svelte
  • Set up and build the SvelteKit application
  • Testing the Svelte-based anon service

Was this helpful?

  1. Anyone SDK
  2. Native SDK
  3. Tutorials

Anyone Services II

Setting Up Services on the Anyone Network

Last updated 6 months ago

Was this helpful?

Integrate SvelteKit with nginx, anon, and anyone-client

This is a follow up from , where we'll give an example of another application set up as a service on the Anyone Network.

"Svelte is a UI framework that uses a compiler to let you write breathtakingly concise components that do minimal work in the browser, using languages you already know โ€” HTML, CSS and JavaScript. Itโ€™s a love letter to web development.

But donโ€™t take our word for it. Developers consistently rank Svelte as the framework theyโ€™re most excited about using."

-

Let's start!

If you haven't followed the steps in the , go ahead and do so before you continue following along in the instructions below.

Set up nginx for SvelteKit

Create a new nginx configuration for the Svelte service:

sudo nano /etc/nginx/sites-available/anon_service_svelte

Add this configuration to route requests to the Svelte app:

server {
    listen 127.0.0.1:5173;
    server_name localhost;

    root /var/www/my-svelte-anon-app/build;
    allow all;
    index index.js;

    location / {
        try_files $uri $uri/ =404;
    }
}

Enable Svelte and Reload nginx:

sudo ln -s /etc/nginx/sites-available/anon_service_svelte /etc/nginx/sites-enabled/
sudo systemctl reload nginx

Configure anyone-client and anon for Svelte

Add port mapping for Svelte to existing anonrc configuration:

cat <<EOL | tee -a ./anon/anonrc
HiddenServicePort 5173 127.0.0.1:5173
EOL

With the Debian package, the anon.service stores the default anonrc in /etc/anon/. Append the port mapping to the configuration with this command and then reload the service:

cat <<EOL | tee -a /etc/anon/anonrc
HiddenServicePort 5173 127.0.0.1:5173
EOL

Reload the anon.service:

sudo systemctl reload anon.service

Set up and build the SvelteKit application

Create a project directory:

mkdir -p ~/anyone
cd ~/anyone

Initialize the project:

npx sv create my-svelte-anon-app

See SvelteKit documentation for more information about setting up projects. We chose these options for the example:

โ”Œ  Welcome to the Svelte CLI! (v0.6.1)
โ”‚
โ—‡  Which template would you like?
โ”‚  SvelteKit minimal
โ”‚
โ—‡  Add type checking with Typescript?
โ”‚  Yes, using Typescript syntax
โ”‚
โ—†  Project created
โ”‚
โ—‡  What would you like to add to your project? (use arrow keys / space bar)
โ”‚  none
โ”‚
โ—‡  Which package manager do you want to install dependencies with?
โ”‚  npm
โ”‚
โ—‡  Successfully installed dependencies
โ”‚
โ—‡  Project next steps โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚                                                                          โ”‚
โ”‚  1: cd my-svelte-anon-app                                                โ”‚
โ”‚  2: git init && git add -A && git commit -m "Initial commit" (optional)  โ”‚
โ”‚  3: npm run dev -- --open                                                โ”‚
โ”‚                                                                          โ”‚
โ”‚  To close the dev server, hit Ctrl-C                                     โ”‚
โ”‚                                                                          โ”‚
โ”‚  Stuck? Visit us at https://svelte.dev/chat                              โ”‚
โ”‚                                                                          โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ
โ”‚
โ””  You're all set!

Install dependencies:

cd my-svelte-anon-app
npm install

Configure the SvelteKit Node Adapter:

npm install -D @sveltejs/adapter-node

Edit the svelte.config.js file located in your project folder. Change the import line to import the new adapter-node:

import adapter from '@sveltejs/adapter-node';

Load environment variables:

npm i dotenv

Add a .env file with PORT and HOSTNAME:

cat <<EOL | tee .env
PORT=5173
HOST=127.0.0.1
EOL

Build the project:

npm run build
#systemctl reload nginx

Move the build output to /var/www/my-svelte-anon-app:

sudo mkdir -p /var/www/my-svelte-anon-app
sudo cp -r build/ /var/www/my-svelte-anon-app/

Testing the Svelte-based anon service

Confirm that the app is accessible locally at http://127.0.0.1:5173:

curl http://127.0.0.1:5173

Access the service via SOCKS5:

Hostname located at: ./anon/anon_service/hostname

curl --socks5-hostname 127.0.0.1:9050 "http://$(cat ./anon/anon_service/hostname):5173"

Hostname located at: /var/lib/anon/anon_service/hostname

curl --socks5-hostname 127.0.0.1:9050 "http://$(cat /var/lib/anon/anon_service/hostname):5173"

If you followed the steps in , we created our custom anonrc in the ./anon folder. Append the port mapping to the configuration with this command:

๐Ÿ”ท
Anon Services I
https://svelte.dev
previous chapter
Anon Services I