﻿# Configure Nginx for external portal

> [HTML Version](nginx-external-portal.html)

This article shows an example of configuring Nginx to access a Service Portal at a designated domain name using a reverse proxy.

````
начало внимание

````
Before you start, you need to enable and activate an [external portal](service-portal.md). 

````
конец внимание

````
We also recommend configuring Nginx for BRIX with a reverse proxy based on the instructions in the [Configure Nginx to use BRIX behind a reverse proxy](nginx-elma365-.md) article.

The following data is used in the example:

- \[OBJECT\]. Name of the workspace with an activated portal.

- \[OBJECT\]. The external portal domain name.

- \[OBJECT\]. The BRIX application domain name.

- \[OBJECT\]. IP address of the server with the BRIX application.

Below are two reverse proxy configurations for accessing an external portal via a dedicated domain using Nginx as example:

Nginx configuration for proxying to an HTTPS server (Kubernetes)

````
server \{  
    listen 80;  
    server\_name portal-brix365client.domain.com;  
    return 301 https://\$server\_name\$request\_uri;  
\}  
  
server \{  
    listen 443 ssl http2;  
    server\_name portal-brix365client.domain.com;  
    set \$brix365\_host brix365client.domain.com;  
    ssl\_certificate /etc/letsencrypt/live/portal-brix365client.domain.com/fullchain.pem;  
    ssl\_certificate\_key /etc/letsencrypt/live/portal-brix365client.domain.com/privkey.pem;  
  
    proxy\_http\_version 1.1;  
    proxy\_cache\_bypass \$http\_upgrade;  
  
    proxy\_set\_header Upgrade \$http\_upgrade;  
    proxy\_set\_header Connection "upgrade";  
    proxy\_set\_header Host \$brix365\_host;  
    proxy\_set\_header X-Real-IP \$remote\_addr;  
    proxy\_set\_header X-Forwarded-For \$proxy\_add\_x\_forwarded\_for;  
    proxy\_set\_header Origin https://\$host;  
  
    proxy\_set\_header Accept-Encoding "";  
    sub\_filter\_types \*;  
    sub\_filter\_once off;  
    sub\_filter '\$brix365\_host' '\$host';  
  
    # redirect required for working with SAML  
    proxy\_redirect http://\$brix365\_host https://\$host;  
  
    location / \{  
        return 301 /\_portal/orders;  
    \}  
  
    location = /index.html \{  
        return 301 /\_portal/orders;  
    \}  
  
    location /\_portal/orders \{  
        proxy\_pass http://192.168.1.10/\_portal/orders;      
\}  
  
    location ~\* ^.+.(jpg|jpeg|gif|png|svg|ico|js|woff|woff|woff2|css|po)\$ \{  
        proxy\_pass http://192.168.1.10;      
\}  
  
    location /ws \{  
        proxy\_pass http://192.168.1.10;      
\}  
  
    location /api \{  
        proxy\_pass http://192.168.1.10;      
\}  
  
    location /s3brix365 \{  
        proxy\_pass http://192.168.1.10;      
\}  
  
    location /guard \{  
        proxy\_pass http://192.168.1.10;      
\}  
  
    location /assets \{  
        proxy\_pass http://192.168.1.10;      
\}  
\}
````

````
Nginx configuration for proxying to an HTTPS server (Kubernetes)

````
server \{  
    listen 80;  
    server\_name portal-brix65client.domain.com;  
    return 301 https://\$server\_name\$request\_uri;  
\}  
  
server \{  
    listen 443 ssl http2;  
    server\_name portal-brix365client.domain.com;  
    set \$brix365\_host brix365client.domain.com;  
    ssl\_certificate /etc/letsencrypt/live/portal-brix365client.domain.com/fullchain.pem;  
    ssl\_certificate\_key /etc/letsencrypt/live/portal-brix365client.domain.com/privkey.pem;  
  
    proxy\_http\_version 1.1;  
    proxy\_cache\_bypass \$http\_upgrade;  
  
    proxy\_set\_header Upgrade \$http\_upgrade;  
    proxy\_set\_header Connection "upgrade";  
    proxy\_set\_header Host \$brix365\_host;  
    proxy\_set\_header X-Real-IP \$remote\_addr;  
    proxy\_set\_header X-Forwarded-For \$proxy\_add\_x\_forwarded\_for;  
    proxy\_set\_header Origin https://\$host;  
  
    proxy\_set\_header Accept-Encoding "";  
    sub\_filter\_types \*;  
    sub\_filter\_once off;  
    sub\_filter '\$brix365\_host' '\$host';  
  
    # reqirect required for working with SAML  
    proxy\_redirect https://\$brix365\_host https://\$host;  
  
    location / \{  
        return 301 /\_portal/orders;  
    \}  
  
    location = /index.html \{  
        return 301 /\_portal/orders;  
    \}  
  
    location /\_portal/orders \{  
        proxy\_pass https://192.168.1.10/\_portal/orders;      
\}  
  
    location ~\* ^.+.(jpg|jpeg|gif|png|svg|ico|js|woff|woff|woff2|css|po)\$ \{  
        proxy\_pass https://192.168.1.10;      
\}  
  
    location /ws \{  
        proxy\_pass https://192.168.1.10;      
\}  
  
    location /api \{  
        proxy\_pass https://192.168.1.10;      
\}  
  
    location /s3brix365 \{  
        proxy\_pass https://192.168.1.10;      
\}  
  
    location /guard \{  
        proxy\_pass https://192.168.1.10;      
\}  
  
    location /assets \{  
        proxy\_pass https://192.168.1.10;      
\}  
\}
````

````
During installation or reconfiguration, in the **Enter host** field, specify \[OBJECT\]** **as the external domain that BRIX will be available at and enable **SSL termination**.

````
начало примечание

````
**Note**

The following parameters are required for the web sockets in the application to work correctly:

- \[OBJECT\].

- \[OBJECT\].

- \[OBJECT\].

The \[OBJECT\] directive will only work if \[OBJECT\]** **is enabled in Nginx.

````
конец примечание
````