Answers.Body: <p>Civi runs ok without internet. Developer installs run in VMs/offline etc all the time. You can disable the update check at Administer - System Settings - Scheduled Jobs.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-08-06T13:43:36.033Z
Answers.Text: Yeah but it doesn't as soon as I enable the firewall it will load indefinitely. I imagine it makes a difference if there is no network interface present at all or if the connection just gets blocked. Wordpress itself is running just fine. When I reset the firewall everything works fine again.
Answers.UserDisplayName: Gellweiler
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-08-06T13:22:46.163Z
Answers.LastActivityDate: 2021-08-06T13:22:46.163Z
Answers.UserDisplayName: Demerit
Answers.Body: <p>Ok it turns out civicrm will work fine without internet when civicrm.org does not get resolved to an ip address. So in the normal scenario when there is simply no internet connection at all, everything works fine because dns will fail. However when dns gets resolved and the ip is not reachable (due to firewall blocking) civicrm will try to contact civicrm.org indefinitely until php or the webserver times out. I've decided to extend my simple ip whitelisting with dns whitelisting using dnsmasq. So now civicrm gets no longer resolved to an ip and everything works smooth.</p>
  <p>A simple workaround if you don't want to setup dns filtering is to add the following to /etc/hosts:</p>
  <pre><code>127.0.0.1 civicrm.org
  </code></pre>
  <p>That way all http requests to civicrm are instead redirected to the local webserver that will respond with a 404 or 403 or a wrong tls certificate.</p>
  <p><strong>Update:</strong> I've wrote a blog post on how to build a whitelist ip/dns filter. Which is what I use for civicrm. You can find it here: <a href="https://craftcodecrew.com/building-a-simple-domain-name-based-firewall-for-egress-filtering/" rel="nofollow noreferrer">https://craftcodecrew.com/building-a-simple-domain-name-based-firewall-for-egress-filtering/</a>.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-08-06T16:44:26.230Z
Answers.LastActivityDate: 2021-09-25T14:54:44.877Z
Answers.LastEditDate: 2021-09-25T14:54:44.877Z
Answers.UserDisplayName: Gellweiler
Body: <p>I tried to install CiviCRM on a server with a firewall that blocks outgoing traffic. But the dashboard wouldn't load. Looking at the logs, it appears CiviCRM tries to connect to civicrm.org. Probably to check for updates. Is there a way to disable all outgoing connections in CiviCRM and run CiviCRM without the server having access to the internet?</p>
  <p><strong>Edit:</strong> If I add 127.0.0.1 civicrm.org&quot; to the host file, everything works. It looks like it's fine if a server returns 403 it just crashes when it can't connect to civicrm.org.</p>
  <h2>Background Story</h2>
  <p>I have a client that stores a lot of sensitive information in CiviCRM. Because of all the security issues that come with all the popular CMS, I lobbied hard to separate CiviCRM from the webpage and to put in onto a separate server and to enforce strict rules for incoming and outgoing traffic.</p>
  <p>So, I moved the CiviCRM to a fresh WordPress installation and put the whole thing behind a nginx reverse proxy that I configured as an authentication proxy with 2FA. The only exception I made is for /civi. We need public access to that path so that links in mailings will work. This works fine and should greatly reduce the attack surface.</p>
  <p>To further improve security, I also want to block all outgoing traffic except for a few whitelisted ip addresses. The goal of this measure is to reduce the risk of malicious code trying to download further code or uploading any data away from the server.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-09-27T13:52:52.937Z
Comments.Text: Your setup sopunds good for teh future you may want to have a look at CiviProxy which would provide access to mailing ressources ans still keeping your whole CiviCRM environment isolated : https://docs.civicrm.org/civiproxy/en/latest/
Comments.UserDisplayName: Fabian
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-09-28T07:05:41.527Z
Comments.Text: @Fabian This is exactly the kind of thing I was looking for. We currently have our own syncing mechanism where we have another civicrm that is a clone of the backend civicrm (without data) attached to the website and then we have a syncing mechanism that exports submitted data to an s3 from where the backend civicrm pulls the data. It works pretty well right now but in the future I might take a look at civiproxy.
Comments.UserDisplayName: Gellweiler
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-09-28T07:13:29.313Z
Comments.Text: Also I only allow GET requests to /civi and throw away any request body. I also block all special characters in the url except for `=, : ?, -, / and %2F` and I don't allow `./` and  `.%2F` and I only allow urls up to 200 characters which should make most attacks that would be theoretically possible against /civi impossible to exploit. And links in newsletters and pixel tracking still works as they use only alphanumeric ids.
Comments.UserDisplayName: Gellweiler
Tags: <security>
Title: Get CiviCRM working without internet connection
ThreadText: # Get CiviCRM working without internet connection
  
  (Asked by: username_0 on 2021-08-06)
  
  I tried to install CiviCRM on a server with a firewall that blocks outgoing traffic. But the dashboard wouldn't load. Looking at the logs, it appears CiviCRM tries to connect to civicrm.org. Probably to check for updates. Is there a way to disable all outgoing connections in CiviCRM and run CiviCRM without the server having access to the internet?
  
  **Edit:** If I add 127.0.0.1 civicrm.org" to the host file, everything works. It looks like it's fine if a server returns 403 it just crashes when it can't connect to civicrm.org.
  
  ## Background Story
  
  I have a client that stores a lot of sensitive information in CiviCRM. Because of all the security issues that come with all the popular CMS, I lobbied hard to separate CiviCRM from the webpage and to put in onto a separate server and to enforce strict rules for incoming and outgoing traffic.
  
  So, I moved the CiviCRM to a fresh WordPress installation and put the whole thing behind a nginx reverse proxy that I configured as an authentication proxy with 2FA. The only exception I made is for /civi. We need public access to that path so that links in mailings will work. This works fine and should greatly reduce the attack surface.
  
  To further improve security, I also want to block all outgoing traffic except for a few whitelisted ip addresses. The goal of this measure is to reduce the risk of malicious code trying to download further code or uploading any data away from the server.
  
  **Tags:** security
  
  > **Comments:**
  > **username_1**: Your setup sopunds good for teh future you may want to have a look at CiviProxy which would provide access to mailing ressources ans still keeping your whole CiviCRM environment isolated : https://docs.civicrm.org/civiproxy/en/latest/  
  > **username_0**: @username_1 This is exactly the kind of thing I was looking for. We currently have our own syncing mechanism where we have another civicrm that is a clone of the backend civicrm (without data) attached to the website and then we have a syncing mechanism that exports submitted data to an s3 from where the backend civicrm pulls the data. It works pretty well right now but in the future I might take a look at civiproxy.  
  > **username_0**: Also I only allow GET requests to /civi and throw away any request body. I also block all special characters in the url except for `=, : ?, -, / and %2F` and I don't allow `./` and  `.%2F` and I only allow urls up to 200 characters which should make most attacks that would be theoretically possible against /civi impossible to exploit. And links in newsletters and pixel tracking still works as they use only alphanumeric ids.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2021-08-06. Score: 4 | Accepted answer
  
  Ok it turns out civicrm will work fine without internet when civicrm.org does not get resolved to an ip address. So in the normal scenario when there is simply no internet connection at all, everything works fine because dns will fail. However when dns gets resolved and the ip is not reachable (due to firewall blocking) civicrm will try to contact civicrm.org indefinitely until php or the webserver times out. I've decided to extend my simple ip whitelisting with dns whitelisting using dnsmasq. So now civicrm gets no longer resolved to an ip and everything works smooth.
  
  A simple workaround if you don't want to setup dns filtering is to add the following to /etc/hosts:
  
  ```
  127.0.0.1 civicrm.org
  
  ```
  
  That way all http requests to civicrm are instead redirected to the local webserver that will respond with a 404 or 403 or a wrong tls certificate.
  
  **Update:** I've wrote a blog post on how to build a whitelist ip/dns filter. Which is what I use for civicrm. You can find it here: <https://craftcodecrew.com/building-a-simple-domain-name-based-firewall-for-egress-filtering/>.
  
  
  ---
  
  ### Answer by username_2 on 2021-08-06. Score: 1
  
  Civi runs ok without internet. Developer installs run in VMs/offline etc all the time. You can disable the update check at Administer - System Settings - Scheduled Jobs.
  
  > **Comments:**
  > **username_0**: Yeah but it doesn't as soon as I enable the firewall it will load indefinitely. I imagine it makes a difference if there is no network interface present at all or if the connection just gets blocked. Wordpress itself is running just fine. When I reset the firewall everything works fine again.  
  
  ---
  
  