Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added NGINX_ENABLED env variable allowing to disable internal nginx… #148

Closed
wants to merge 1 commit into from

Conversation

vladm
Copy link

@vladm vladm commented Sep 21, 2015

Allows disabling internal nginx server in favor to using with an external proxy server.

@sameersbn
Copy link
Owner

Using unicorn to handle static web requests is not a great idea. Unicorn is a ruby process and takes a lot of system resources, as result we end up limiting the number of unicorn processes. If unicorn is left to handle requests to static asstes, it can make redmine unresponsive when users are downloading large files from your redmine server as unicorn will be busy handling the download request instead of doing something useful. At the same time, user will have to increase the unicorn timeout to make sure the download by a slow client is not prematurely closed before the download is completed.

I have seen this issue in action and how it affects the responsiveness of a ruby app when a client is downloading a large file and/or the download speed of the client is very slow. It is therefore advisable that static file requests are handled by a web server, instead of asking unicorn to do this heavy lifting.

@vladm
Copy link
Author

vladm commented Oct 18, 2015

thank you for your thoughtful response.

in some cases (like ours) host is already running nginx for other needs, so running a dedicated nginx instance just for redmine is unnecessary and I ended up proxying to redmine using "external" installation of nginx. one can configure that external web/proxy server to serve location of static files (since it's stored on the host) using rewrite or alias mechanisms.

same thoughts apply to the cron server that is started inside redmine container. I'd love to be able to optionally disable it and moving this functionality to the external cron server (execute commands inside container via docker exec, for instance).

in general, the idea is to be able to run a "naked" redmine container with all the supportive services (like db, cron, nginx) running outside (or within other, separate containers). speaking of - this is how docker team suggest containers to be built: a single-service ones.

if you agree that this is a valuable optional feature to be included, I can work to polish my patch (tweak doc?) and further extend this approach onto cron server as described above.

thanks.

@sameersbn
Copy link
Owner

@vladm it is true that docker suggests having only one service per container. But this is difficult to get working in applications that require external services like cron without having a complicated setup guide. I know it is possible to run cron on the host and perform tasks in the container using docker exec, it however does affect the portability of the container. i.e. you will not be able to move the container to another host without also moving all the extra setup that you may have performed on the host.

However if you think this is something you need, then I have no issues, you can add a config option to disable CRON, just make sure that the effects of doing this are well documented in the README, so that users know what they are signing up for.

With regard to disabling NGINX, again if you think this is the right solution for you, then I will be happy to merge this PR. But you will need to document it well in the README as in the case of disabling CRON and also support users who decide take the same path.

Lastly, I dont know if you have used this PR in production. But i would suggest you run your changes in production on a decent size installation and see how it behaves before committing to this change. I have seen the effects of disabling nginx in production. As a matter of fact, nginx was once removed from this image for a brief period and I quickly reverted the changes when things started falling apart.

As far as the PR goes, if you want to disable NGINX then all you need to do is disable its startup in the /etc/supervisor/conf.d/nginx.conf by setting autostart=false. You dont need to surround all the code blocks with if [[ ${NGINX_ENABLED} == true ]] everywhere, just disable nginx startup and that should disable nginx. You only need to do the unicorn changes.

Also, the install.sh script executes at build time so NGINX_ENABLED=false will not have any effect at runtime on this script, since it is already executed.

If you are commited to this PR, then let me know, I will comment inline on your PR to get it right.

@vladm
Copy link
Author

vladm commented Nov 16, 2015

we do run this in production, however I think you are missing the point of why I'm disabling nginx / cron. It's not to expose unicorn directly to the world, but to utilize nginx that we already run on the host for other needs. I don't want to run another nginx within redmine container nor I want to do double-proxying... So, instead of going:

user => host nginx => [ nginx within container => unicorn within container ]

we are able to do this:
user => host nginx => [ unicorn within container ].

I'll update the README with a more detailed explanation for disabling nginx within container and rework it with your suggestions.

I can't 100% agree with the notion that "removing nginx & cron leads to less portability" - I think a different approach should be used: separating those extra services, like nginx, cron, etc into individual containers and utilizing docker-compose to provide user with a fully deployed app, consisting of multiple services. This should also allow for more flexibility for deployment like ours - letting us run cron + nginx + db outside of "redmine" container.

@sameersbn sameersbn closed this in 2852b2f Dec 16, 2015
@laoshancun
Copy link

laoshancun commented Nov 28, 2016

hi , i have add NGINX_ENABLED=false to env ,but nginx process is still runing. and unicorn is listen on 127.0.0.1,how to solve this ?

here is info

root@9b8eccde0900-redmine-redmine-1:/home/redmine/redmine# env |grep NGINX
NGINX_ENABLED=false
root@9b8eccde0900-redmine-redmine-1:/home/redmine/redmine# netstat -lnp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 127.0.0.11:42561        0.0.0.0:*               LISTEN      -
tcp        0      0 127.0.0.1:8080          0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      120/nginx -g daemon
tcp6       0      0 :::80                   :::*                    LISTEN      120/nginx -g daemon
udp        0      0 127.0.0.11:37266        0.0.0.0:*                           -
Active UNIX domain sockets (only servers)
Proto RefCnt Flags       Type       State         I-Node   PID/Program name    Path
unix  2      [ ACC ]     STREAM     LISTENING     95062788 -                   /home/redmine/redmine/tmp/sockets/redmine.socket
unix  2      [ ACC ]     STREAM     LISTENING     95070386 1/python            /var/run/supervisor.sock.1

and my docker-compose.yml

mysql-server:
  image: mysql:5.7
  volumes:
    - /data/docker/redmine/mysql/data:/var/lib/mysql
    - /data/docker/redmine/mysql/docker.cnf:/etc/mysql/conf.d/docker.cnf
  ports:
    - "3306:3306"
  environment:
  user: root
redmine:
  image: sameersbn/redmine:3.1.1
  environment:
    #- DOCKER_HOST=192.168.2.115
    - DB_HOST=mysql-server
    - DB_TYPE=mysql
    - DB_NAME=redmine
    - DB_USER=redmine
    - DB_PASS=password
    - TZ=Asia/Shanghai
    - REDMINE_PORT=80
    - NGINX_ENABLED=false
    - SMTP_ENABLED=true
    - SMTP_DOMAIN=test.com
    - SMTP_HOST=smtp.test.com
    - SMTP_PORT=25
    - [email protected]
    - SMTP_PASS=password
    - SMTP_STARTTLS=true
    - SMTP_AUTHENTICATION=:login
    - IMAP_ENABLED=false
    - [email protected]
    - IMAP_PASS=password
    - IMAP_HOST=imap.gmail.com
    - IMAP_PORT=993
    - IMAP_SSL=true
    - IMAP_INTERVAL=30
  links:
   - mysql-server:mysql-server
  ports:
    - "10083:8080"
  volumes:
    - /data/docker/redmine/server:/home/redmine/data

ZarTek-Creole added a commit to ZarTek-Creole/docker-redmine that referenced this pull request Jul 10, 2024
jcormier added a commit that referenced this pull request Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants