Welcome! Log In Create A New Profile

Advanced

Unable to create nginx loadbalancer

Posted by pentagonuser 
Unable to create nginx loadbalancer
June 29, 2023 11:50PM
My terraform code is below:
```
resource "azurerm_resource_group" "example" {
provider = azurerm.lab_lz1
name = "example-rg"
location = "West Europe"
}

resource "azurerm_virtual_network" "example" {
provider = azurerm.lab_lz1
name = "example-vnet"
address_space = ["10.0.0.0/16"]
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
}

resource "azurerm_subnet" "example" {
provider = azurerm.lab_lz1
name = "example-subnet"
resource_group_name = azurerm_resource_group.example.name
virtual_network_name = azurerm_virtual_network.example.name
address_prefixes = ["10.0.2.0/24"]
delegation {
name = "delegation"

service_delegation {
name = "NGINX.NGINXPLUS/nginxDeployments"
actions = [
"Microsoft.Network/virtualNetworks/subnets/join/action",
]
}
}
}
resource "azurerm_network_interface" "example" {
provider = azurerm.lab_lz1
name = "example-nic"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_resource_group.example.location

ip_configuration {
name = "example-ipconfig"
subnet_id = azurerm_subnet.example.id
private_ip_address_allocation = "Static"
private_ip_address = "10.0.2.10" # Set the desired private IP address
}
}
resource "azurerm_nginx_deployment" "example" {
provider = azurerm.lab_lz1
name = "example-nginx"
resource_group_name = azurerm_resource_group.example.name
sku = "publicpreview_Monthly_gmz7xq9ge3py"
location = azurerm_resource_group.example.location
managed_resource_group = "example"
diagnose_support_enabled = true

frontend_private {
allocation_method = "Static"
ip_address = azurerm_network_interface.example.private_ip_address
subnet_id = azurerm_subnet.example.id
}

network_interface {
subnet_id = azurerm_subnet.example.id
}
}

resource "azurerm_nginx_configuration" "example" {
provider = azurerm.lab_lz1
nginx_deployment_id = azurerm_nginx_deployment.example.id
root_file = "/etc/nginx/nginx.conf"

config_file {
content = base64encode(<<-EOT
http {
server {
listen 80;
location / {
default_type text/html;
return 200 '<!doctype html><html lang="en"><head></head><body>
<div>this one will be updated</div>
<div>at 10:38 am</div>
</body></html>';
}
include site/*.conf;
}
}
EOT
)
virtual_path = "/etc/nginx/nginx.conf"
}

config_file {
content = base64encode(<<-EOT
location /bbb {
default_type text/html;
return 200 '<!doctype html><html lang="en"><head></head><body>
<div>this one will be updated</div>
<div>at 10:38 am</div>
</body></html>';
}
EOT
)
virtual_path = "/etc/nginx/site/b.conf"
}
}```

However, I am getting errors like:

```
│ Error: creating Nginx Deployment (Subscription: "xxxxxxxxxxxxxxxx"
│ Resource Group Name: "example-rg"
│ Nginx Deployment Name: "example-nginx"): performing DeploymentsCreateOrUpdate: nginxdeployment.NginxDeploymentClient#DeploymentsCreateOrUpdate: Failure sending request: StatusCode=0 -- Original Error: Code="InternalServerError" Message="Internal Server Error"

│ with azurerm_nginx_deployment.example,
│ on Nginx-Deployment.tf line 45, in resource "azurerm_nginx_deployment" "example":
│ 45: resource "azurerm_nginx_deployment" "example" {

│ creating Nginx Deployment (Subscription: "xxxxxxxxxxxxxx"
│ Resource Group Name: "example-rg"
│ Nginx Deployment Name: "example-nginx"): performing DeploymentsCreateOrUpdate:
│ nginxdeployment.NginxDeploymentClient#DeploymentsCreateOrUpdate: Failure sending request: StatusCode=0 --
│ Original Error: Code="InternalServerError" Message="Internal Server Error"
╵```

WOndering if anyone has Created NginxLB on Azure?
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 147
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready