# Disable direct access with port (nginx)

**URL:** <https://meta.discourse.org/t/disable-direct-access-with-port-nginx/31312>\
**Category:** Self-hosting\
**Created:** [July 22, 2015, 8:40pm UTC](https://meta.discourse.org/t/disable-direct-access-with-port-nginx/31312 "2015-07-22T20:40:22Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![preDawnHunter](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/predawnhunter/32/116445_2.png) [@preDawnHunter](https://meta.discourse.org/u/preDawnHunter)\
**Post date:** [July 22, 2015, 8:40pm UTC](https://meta.discourse.org/t/disable-direct-access-with-port-nginx/31312/1 "2015-07-22T20:40:22Z")

</div>

I am not sure if I could the problem clear but I will try my best. 😁

I set up the Discourse on port 9988 and proxy it to subdomain, [http://d.abc.com/](http://d.abc.com/), with nginx. It works. However, I can still access it from [http://abc.com:9988/](http://abc.com:9988/) and [http://d.abc.com:9988/](http://d.abc.com:9988/). How can I completely disable the access to the port?

I am using Digital Ocean droplet and both top and subdomain are on the same droplet.

Below is my conf for both sites (in one file).

```
server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    server_name fuguo.uk; # Replace with your domain

    location / {
         root /var/www/abc.com;
         index index.html index.htm;
    }
}

server {
    listen 80;
    server_name d.abc.com # Replace with your domain

    location / {
        proxy_pass http://localhost:9988;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_buffering off;
    }
}

```

Many thanks.

---

_[View the full topic](https://meta.discourse.org/t/disable-direct-access-with-port-nginx/31312)._
