# 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:** 3
**Page:** 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.

---

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [July 22, 2015, 9:21pm UTC](https://meta.discourse.org/t/disable-direct-access-with-port-nginx/31312/2 "2015-07-22T21:21:39Z")

</div>

Your can use a firewall like `iptables` to block access to this port.

Alternatively, you can follow [this guide](https://meta.discourse.org/t/running-other-websites-on-the-same-machine-as-discourse/17247) to use a socket instead of a port, eliminating the need to block any port 🙂

---

<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, 9:36pm UTC](https://meta.discourse.org/t/disable-direct-access-with-port-nginx/31312/4 "2015-07-22T21:36:56Z")

</div>

@fefrei Thank you! You are the best! 😘
