# Comment désactiver l'accès pour tout utilisateur ne provenant pas d'une adresse IP spécifique

**URL:** https://meta.discourse.org/t/how-to-disable-access-to-anyone-not-coming-from-a-specific-ip-address/114907
**Category:** Self-hosting
**Created:** [Avril 13, 2019, 1:02 UTC](https://meta.discourse.org/t/how-to-disable-access-to-anyone-not-coming-from-a-specific-ip-address/114907 "2019-04-13T01:02:16Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![sat](https://avatars.discourse-cdn.com/v4/letter/s/22d042/32.png) [@sat](https://meta.discourse.org/u/sat)
#### Post date: [Avril 13, 2019, 1:02 UTC](https://meta.discourse.org/t/how-to-disable-access-to-anyone-not-coming-from-a-specific-ip-address/114907/1 "2019-04-13T01:02:16Z")

</div>

I would like to block access to my discourse forum until it is ready but would like to have access to only few IP address so that our team can work on forum.

I do know below options can be enable but I want my team to see forum like regular user until it is ready and work on content.  
settings-\>login  
Public registration is disabled, all new users must be explicitly invited by trusted users or staff.  
Require authentication to read content on this site, disallow anonymous access.

When outside user(non approved IP address) visit my site they should see nothing there.

Thanks for your help!

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [Avril 13, 2019, 1:24 UTC](https://meta.discourse.org/t/how-to-disable-access-to-anyone-not-coming-from-a-specific-ip-address/114907/2 "2019-04-13T01:24:16Z")

</div>

If you use the setup wizard that launches after first install, you can select a private instance in one of the first steps. If you need to re-run the wizard you can do so at `/wizard`

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [Avril 13, 2019, 3:09 UTC](https://meta.discourse.org/t/how-to-disable-access-to-anyone-not-coming-from-a-specific-ip-address/114907/3 "2019-04-13T03:09:53Z")

</div>

If you really want to limit access by ip then you could use iptables or nginx rules.

---

<div class="post-metadata">

### Author: ![sat](https://avatars.discourse-cdn.com/v4/letter/s/22d042/32.png) [@sat](https://meta.discourse.org/u/sat)
#### Post date: [Avril 13, 2019, 4:20 UTC](https://meta.discourse.org/t/how-to-disable-access-to-anyone-not-coming-from-a-specific-ip-address/114907/4 "2019-04-13T04:20:06Z")

</div>

> [@codinghorror](#):
>
> If you use the setup wizard that launches after first install, you can select a private instance in one of the first steps. If you need to re-run the wizard you can do so at `/wizard`

This will not show posts to users I want, they need to login to see content. It is similar to enabling 2 options which I mentioned in my above post.

> [@pfaffman](#):
>
> If you really want to limit access by ip then you could use iptables or nginx rules.

I dont know how to do that. could you please provide steps.

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [Avril 13, 2019, 4:25 UTC](https://meta.discourse.org/t/how-to-disable-access-to-anyone-not-coming-from-a-specific-ip-address/114907/5 "2019-04-13T04:25:56Z")

</div>

> [@sat](#):
>
> This will not show posts to users I want, they need to login to see content

Easy. Set forum to private as Jeff suggests and then approve access to only your setup team. If you don’t approve others they will only see the login screen. You can set permissions to categories by group if you need further granularity.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [Avril 13, 2019, 4:27 UTC](https://meta.discourse.org/t/how-to-disable-access-to-anyone-not-coming-from-a-specific-ip-address/114907/6 "2019-04-13T04:27:02Z")

</div>

You don’t like the discourse solution, so it’s a sysadmin issue. You can Google stuff like “block ip with iptables” or ‘limit ip access nginx". You might try’ “ufw” instead of iptables.

If you have a budget I might be able to help. My contact info is in my profile.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [Avril 13, 2019, 2:53 UTC](https://meta.discourse.org/t/how-to-disable-access-to-anyone-not-coming-from-a-specific-ip-address/114907/7 "2019-04-13T14:53:08Z")

</div>

Another way to do it is to remove the dns A record for the forum and have your testers hard code the ip on their machines.

---

<div class="post-metadata">

### Author: ![sat](https://avatars.discourse-cdn.com/v4/letter/s/22d042/32.png) [@sat](https://meta.discourse.org/u/sat)
#### Post date: [Avril 13, 2019, 3:10 UTC](https://meta.discourse.org/t/how-to-disable-access-to-anyone-not-coming-from-a-specific-ip-address/114907/8 "2019-04-13T15:10:04Z")

</div>

@pfaffman thank you for the pointers.

I fixed it 🙂 Here is solution in case someone needs it.

1. `./launcher enter app` from /var/discourse folder
2. Go to '/etc/nginx/ folder and create file ‘whitelist-ip.conf’
3. add below lines in ‘whitelist-ip.conf’ file  
allow 192.168.1.1;  
deny all;
4. open `/etc/nginx/conf.d/discourse.conf`
5. go to line no 37 see below section, it is for port 443  
server {  
include /etc/nginx/whitelist-ip.conf;  
}
6. add line ‘include /etc/nginx/whitelist-ip.conf;’
7. Test NginX configuration by running command ‘nginx -t’
8. run ‘service nginx reload’

Try now, it will show not found page. no page related to discourse. from whiteliet ip address it will show normal forum.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [Avril 13, 2019, 5:08 UTC](https://meta.discourse.org/t/how-to-disable-access-to-anyone-not-coming-from-a-specific-ip-address/114907/9 "2019-04-13T17:08:11Z")

</div>

Nice work!

And note that when you rebuild the container those changes will go away. This can be ether a bug or a feature!

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [Mai 13, 2019, 5:11 UTC](https://meta.discourse.org/t/how-to-disable-access-to-anyone-not-coming-from-a-specific-ip-address/114907/10 "2019-05-13T17:11:40Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
