---
title: CORS - Nginx Custom Cert
slug: aiops2/cors-nginx-custom-cert
description: Learn how to configure Haproxy version 2.2 or higher for enabling CORS on frontends 80 and 443 with this comprehensive document. Discover step-by-step instructions for adding necessary options to the frontends and creating a dedicated backend, "cors_backe
docTags: 
createdAt: 2023-10-20T18:17:13.035Z
---

:::CodeblockTabs
Observações

```Text
Pré-requesito: Haproxy versão 2.2 ou superior
```
:::

## Nos frontends 80 e 443 adicionar:

```ini
capture request header origin len 128
acl is_options method OPTIONS
acl is_head method HEAD
use_backend cors_backend if is_options or is_head
```

## Criar backend cors\_backend com as seguintes opções:

```ini
backend cors_backend
http-after-response add-header Access-Control-Allow-Origin "https://<dominio>"
http-after-response set-header Access-Control-Allow-Credentials "true"
http-after-response set-header Access-Control-Allow-Methods "GET,HEAD,OPTIONS,POST,PUT"
http-after-response set-header Access-Control-Allow-Headers "accept-language,authorization,X-CSRF-Token"
http-after-response set-header Access-Control-Max-Age "31536000"
http-request return status 200
```

