Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

[chore] added option to add more hosts to rails server

Eric Schubert143ba2780315
diff --git a/config/environments/development.rb b/config/environments/development.rb
index 7b024ec4ee8..ba823dea486 100644
--- a/config/environments/development.rb
+++ b/config/environments/development.rb
@@ -81,6 +81,10 @@ OpenProject::Application.configure do
config.action_mailer.delivery_method = :letter_opener
config.hosts << 'bs-local.com' if ENV['OPENPROJECT_DISABLE_DEV_ASSET_PROXY'].present?
+
+ if ENV['OPENPROJECT_DEV_EXTRA_HOSTS'].present?
+ config.hosts.push(*ENV['OPENPROJECT_DEV_EXTRA_HOSTS'].split(','))
+ end
end
-ActiveRecord::Base.logger = ActiveSupport::Logger.new(STDOUT) unless String(ENV["SILENCE_SQL_LOGS"]).to_bool
+ActiveRecord::Base.logger = ActiveSupport::Logger.new($stdout) unless String(ENV["SILENCE_SQL_LOGS"]).to_bool
diff --git a/docs/development/localhost-ssl/README.md b/docs/development/localhost-ssl/README.md
index 58464c3e937..e779c80feb3 100644
--- a/docs/development/localhost-ssl/README.md
+++ b/docs/development/localhost-ssl/README.md
@@ -1,41 +1,41 @@
# Developing OpenProject locally with HTTPS
-In some cases, running OpenProject locally with https can be useful for development. For example, if your testing or developing an OmniAuth plugin, you'll want to be able to return to OpenProject running under https.
-
-This guide will instruct you how to install and configure an Apache2 proxy/reverse-proxy pattern with OpenProject. This closely matches the way OpenProject is run in production systems for packaged and docker-based installations.
-
+In some cases, running OpenProject locally with https can be useful for development. For example, if your testing or
+developing an OmniAuth plugin, you'll want to be able to return to OpenProject running under https.
+This guide will instruct you how to install and configure an Apache2 proxy/reverse-proxy pattern with OpenProject. This
+closely matches the way OpenProject is run in production systems for packaged and docker-based installations.
## Step 1: Create a self-signed certificate
-You will need a certificate to terminate SSL requests at Apache. For development purposes only, create a self-signed certificate as follows:
+You will need a certificate to terminate SSL requests at Apache. For development purposes only, create a self-signed
+certificate as follows:
```bash
sudo mkdir -p /etc/ssl/openproject-dev/
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/openproject-dev/privkey.key -out /etc/ssl/openproject-dev/cert.crt
```
-
-
This will output a private key and certificate to `/etc/ssl/openproject-dev` for use with Apache2.
-
-
## Step 2: Set up a custom host
-You may want to have a full host name available for development. Let's assume this is `openproject.example.com`. You can forward this hostname to your local machine by editing `/etc/hosts` and adding `openproject.example.com 127.0.0.1` to it.
-
-
+You may want to have a full host name available for development. Let's assume this is `openproject.example.com`. You can
+forward this hostname to your local machine by editing `/etc/hosts` and adding `openproject.example.com 127.0.0.1` to
+it.
## Step 3: Install and configure Apache2
-First, you'll need to install the Apache2 web server. The actual command will differ depending on your actual distribution. For apt-based systems, the following command is used:
+First, you'll need to install the Apache2 web server. The actual command will differ depending on your actual
+distribution. For apt-based systems, the following command is used:
```bash
sudo apt-get install apache2
```
-Next, ensure that `mod_ssl`, `mod_proxy`, `mod_proxy_http` and `mod_headers` are installed and active. Read up in your distribution's apache configuration on how to enable them. You can check the output of `apachectl -M` and verify they are being loaded.
+Next, ensure that `mod_ssl`, `mod_proxy`, `mod_proxy_http` and `mod_headers` are installed and active. Read up in your
+distribution's apache configuration on how to enable them. You can check the output of `apachectl -M` and verify they
+are being loaded.
You will then add a configuration for OpenProject under:
@@ -84,36 +84,57 @@ The following contains an exemplary configuration:
```
+Save the configuration file, activate it (e.g. with `sudo a2ensite openproject-dev-ssl.conf`) and reload the Apache2
+server. Ensure the syntax is correct with `apachectl configtest`.
-
-Save the configuration file, activate it (e.g. with `sudo a2ensite openproject-dev-ssl.conf`) and reload the Apache2 server. Ensure the syntax is correct with `apachectl configtest`.
-
-In case you're in an environment with SELinux enabled, you will also need to allow Apache2 to connect locally to the application server. You can do that with `/usr/sbin/setsebool -P httpd_can_network_connect 1`.
-
-
+In case you're in an environment with SELinux enabled, you will also need to allow Apache2 to connect locally to the
+application server. You can do that with `/usr/sbin/setsebool -P httpd_can_network_connect 1`.
## Step 4: Configure OpenProject for HTTPS usage
-We assume you have already configured your OpenProject local development environment as [described in this guide](../development-environment-ubuntu). You will need to add your custom host name to `config/environments/development.rb`:
+We assume you have already configured your OpenProject local development environment
+as [described in this guide](../development-environment-ubuntu). You will need to add your custom host name
+to the environment. You can use this variable to do so.
-```ruby
-Rails.application.config.hosts << 'openproject.example.com'
+```yaml
+OPENPROJECT_DEV_EXTRA_HOSTS: 'openproject.example.com'
```
-
-
-Then, you will to set the following settings
+Then, you need to set the following settings
```ruby
export OPENPROJECT_HTTPS = true
export OPENPROJECT_HOST__NAME = 'openproject.example.com'
```
-Finally, start your OpenProject development server and Frontend server and access `https://openproject.example.com` in your browser.
+Finally, start your OpenProject development server and Frontend server and access `https://openproject.example.com` in
+your browser.
+
+## Alternative: Docker development environment
+
+Alternatively to the previously described steps, you can alter you docker-based local installation. To do so, you must
+setup a reverse proxy in docker, like [traefik](https://traefik.io/). Then follow these bullet points:
+
+- create a `docker-compose.override.yml`
+- make your openproject services visible with specific host names, i.e. with `traefik` this means adding labels to the
+ services defined host routers
+ ```yaml
+ labels:
+ - "traefik.http.routers.op-backend.rule=Host(`op-backend.local`)"
+ ```
+- add the extra hosts to your `/etc/hosts` to redirect to `localhost`
+- add the extra hosts to your `backend` service with
+ ```yaml
+ OPENPROJECT_DEV_EXTRA_HOSTS: 'op-backend.local,op-backend.local'
+ ```
+#### Reminder
+This setup is still experimental and under further development. Use it only, when you know what you are doing.
## Questions, Comments, and Feedback
-If you have any further questions, comments, feedback, or an idea to enhance this guide, please tell us at the appropriate community.openproject.org [forum](https://community.openproject.org/projects/openproject/boards/9).
-[Follow OpenProject on twitter](https://twitter.com/openproject), and follow [the news](https://www.openproject.org/blog) to stay up to date.
+If you have any further questions, comments, feedback, or an idea to enhance this guide, please tell us at the
+appropriate community.openproject.org [forum](https://community.openproject.org/projects/openproject/boards/9).
+[Follow OpenProject on twitter](https://twitter.com/openproject), and
+follow [the news](https://www.openproject.org/blog) to stay up to date.