# Using nginx as proxy server is very slow, but it is very fast if using nginx in docker! Why?

**URL:** <https://meta.discourse.org/t/using-nginx-as-proxy-server-is-very-slow-but-it-is-very-fast-if-using-nginx-in-docker-why/168972>\
**Category:** Self-hosting\
**Created:** [November 2, 2020, 8:44am UTC](https://meta.discourse.org/t/using-nginx-as-proxy-server-is-very-slow-but-it-is-very-fast-if-using-nginx-in-docker-why/168972 "2020-11-02T08:44:35Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![cosoc](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cosoc/32/198738_2.png) [@cosoc](https://meta.discourse.org/u/cosoc)\
**Post date:** [November 2, 2020, 8:44am UTC](https://meta.discourse.org/t/using-nginx-as-proxy-server-is-very-slow-but-it-is-very-fast-if-using-nginx-in-docker-why/168972/1 "2020-11-02T08:44:35Z")

</div>

Using nginx as proxy server is very slow, but it is very fast if using nginx in docker! Why?

app.yml

```plaintext
templates:
  #- "templates/postgres.template.yml"
  - "templates/redis.template.yml"
  - "templates/web.template.yml"
  - "templates/sshd.template.yml"
  - "templates/web.ratelimited.template.yml"
## Uncomment these two lines if you wish to add Lets Encrypt (https)
  #- "templates/web.ssl.template.yml"
  #- "templates/web.letsencrypt.ssl.template.yml"
  - "templates/web.socketed.template.yml"

expose:
  #- "8080:80" # http
  #- "444:443" # https

params:
  db_default_text_search_config: "pg_catalog.english"

  ## Set db_shared_buffers to a max of 25% of the total memory.
  ## will be set automatically by bootstrap based on detected RAM, or you can override
  db_shared_buffers: "780MB"

  ## can improve sorting performance, but adds memory usage per-connection
  # db_work_mem: "512MB"

  ## Which Git revision should this container use? (default: tests-passed)
  version: stable

env:
  # 数据库配置
  DISCOURSE_DB_USERNAME: ****
  DISCOURSE_DB_PASSWORD: ***
  DISCOURSE_DB_HOST: ***
  DISCOURSE_DB_NAME: ***
  DISCOURSE_DB_PORT: ***
  DISCOURSE_DB_BACKUP_PORT: ***

  LANG: zh_CN.UTF-8
  DISCOURSE_DEFAULT_LOCALE: zh_CN

  ## How many concurrent web requests are supported? Depends on memory and CPU cores.
  ## will be set automatically by bootstrap based on detected CPUs, or you can override
  UNICORN_WORKERS: 2

```

nginx config

```plaintext
server {
    listen 80; listen [::]:80;
    server_name my.web.org;

    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl http2; listen [::]:443 ssl http2;
    server_name minetest.cosoc.org;

    ssl_certificate /var/discourse/shared/standalone/ssl/my.web.org.cer;
    ssl_certificate_key /var/discourse/shared/standalone/ssl/my.web.org.key;
    ssl_session_tickets off;
    http2_idle_timeout 5m; # up from 3m default

location / {
        proxy_pass http://unix:/var/discourse/shared/standalone/nginx.http.sock;
        proxy_set_header Host $http_host;
        proxy_http_version 1.1;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto https;
        proxy_set_header X-Real-IP $remote_addr;
    }

```

Why is nginx acting so slowly??? But it’s fast when you don’t use it!!

---

_[View the full topic](https://meta.discourse.org/t/using-nginx-as-proxy-server-is-very-slow-but-it-is-very-fast-if-using-nginx-in-docker-why/168972)._
