nixos/hosts/nixos-test/configuration.nix
Florian RICHER f849d99dcc
All checks were successful
check / check (push) Successful in 32s
nixos-vm: First proxy work
2024-10-25 14:59:46 +02:00

71 lines
1.5 KiB
Nix
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running nixos-help).
{ config, pkgs, ... }:
{
imports =
[
../../modules/system
# Include the results of the hardware scan.
./hardware-configuration.nix
];
# Bootloader.
boot.loader = {
grub = {
enable = true;
device = "/dev/vda";
efiSupport = false;
useOSProber = true;
};
};
networking.hostName = "nixos-vm"; # Define your hostname.
users.users.florian.initialPassword = "test";
# Configure for testing in vm
virtualisation.vmVariant = {
# following configuration is added only when building VM with build-vm
virtualisation = {
memorySize = 8192; # Use 8192MiB memory.
cores = 8;
forwardPorts = [
{ from = "host"; host.port = 8888; guest.port = 80; }
];
};
};
modules.system = {
server = {
docker.enable = true;
openssh.enable = true;
};
hardware = {
keymaps.layout = "us";
};
};
# Run containers
virtualisation.oci-containers.containers."hello" = {
image = "docker.io/nginxdemos/hello:latest";
ports = [
"9000:80/tcp"
];
};
services.nginx = {
enable = true;
virtualHosts."hello.local" = {
locations."/" = {
proxyPass = "http://127.0.0.1:9000";
};
};
};
networking.firewall.allowedTCPPorts = [ 80 ]; # Opens port 80 for HTTP traffic.
}