# NIGNX

`sudo apt install nginx`

#### <mark style="color:yellow;">Turn Nginx into a reverse proxy</mark>

`sudoedit /etc/nginx/sites-available/default`

inside location curly braces:

```sh
location / {
    proxy_pass 
    http://site2.homelab.lan:8080
    ;
    #….more config
}
```

how to pass proxy information to backend

for security purposes or marketing information, backend servers dosen’t know about client or end users, because they are hitting the nginx reverse proxy and for that we’ll use some special config

in /etc/nginx/conf.d

create a file with any name you want and add this ( this is for centos )

{% hint style="info" %}
If you are in ubuntu you can crate your .conf file inside sites-available then make a symlink to sites-enabled
{% endhint %}

`[root@k8s-manager nginx]# cat ./conf.d/reverse-proxy.conf`

```bash
server {
    listen 80;
    server_name centos.homelab.lan;

    location / {
        proxy_pass <https://dev.to/taqiyeddinedj>;
        #proxy_set_header Host $host;
        #proxy_set_header X-Real-IP $remote_addr;
        #proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}
```
