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

PWA Requirement / http2 #431

Closed
wolfwahl opened this issue Nov 25, 2018 · 16 comments · Fixed by #462
Closed

PWA Requirement / http2 #431

wolfwahl opened this issue Nov 25, 2018 · 16 comments · Fixed by #462

Comments

@wolfwahl
Copy link

Hi,

could you provide a sample on how to configure devilbox to serve request on apache and nginx via http/2 ?

tnx!

@science695
Copy link

Hello @wolfwahl,

Currently devilbox is setup to use nginx or apache, not both.

However, the docs have a good explaination about where you can choose which web server to run:
https://devilbox.readthedocs.io/en/latest/getting-started/change-container-versions.html?highlight=nginx#change-web-server-version

@wolfwahl
Copy link
Author

@science695 is my English really that bad? :-/

It's very well documented how to configure which web server to use.

But I would like to know how to configure devilbox either one of these servers (nginx or apache) to serve responses via http/2

@science695
Copy link

science695 commented Nov 26, 2018

I'm sorry I misunderstood you, I wasn't fully sure what you were asking for.

Okay, you are asking about http/2.

I am not super familiar with http/2 configuration, but I believe to do that you need to change the virtualhost configuration in nginx or apache.

WIth devilbox, you can customize the generated virtual hosts. Here is the document page for that:
https://devilbox.readthedocs.io/en/latest/vhost-gen/customize-all-virtual-hosts-globally.html?highlight=nginx

@wolfwahl
Copy link
Author

Nope, for apache e.g. you need to enable a module + configuration.
For nginx it could probably been achieved by configuration only, but I had no success till now. The documented workaround to provide a nginx.conf file will not work - throws "bad command" errors on the commands needed.

@science695
Copy link

This will probably require @cytopia to add those modules to the docker image.

If you can describe what needs to be installed, cytopia does a great job developing devilbox and adding features.

@cytopia
Copy link
Owner

cytopia commented Dec 10, 2018

@wolfwahl I myself do not have any experience with http2 yet. Do you have some example configurations for nginx/apache as well as what modules are required to make it work?

@wolfwahl
Copy link
Author

@cytopia maybe that would provide a good start?

https://geekflare.com/http2-implementation-apache-nginx/

Would really appreciate an (maybe optional) implementation of http2

@daanggc
Copy link

daanggc commented Jan 4, 2019

@cytopia @wolfwahl
I added the following lines to devilbox/cfg/apache-2.4/devilbox-custom.conf

LoadModule http2_module modules/mod_http2.so
Protocols h2 h2c http/1.1
ProtocolsHonorOrder Off

(The last one isn't required, but I like it)

Now it just works :) (Only on HTTPS, as required by HTTP2)

@cytopia
Copy link
Owner

cytopia commented Jan 4, 2019

@daancart2quote thanks for the info.

How can I actually test that I am using http2?

@wolfwahl
Copy link
Author

wolfwahl commented Jan 5, 2019

@daancart2quote great! Cheers mate!

@cytopia -> Browser -> Developer Tools -> Networking -> enable Protocol (Chrome: right click Table-Header)

@cytopia
Copy link
Owner

cytopia commented Jan 5, 2019

@wolfwahl Awesome!

I've also tried it with Nginx its as simple as:

    listen       443 ssl http2 default_server;

However when editing vhost-gen configs this will be added to http and https configs and then http will stop working. I will built this into vhost-gen so it will be correctly configured depending on SSL or not

@wolfwahl
Copy link
Author

wolfwahl commented Jan 5, 2019

@cytopia This is not working for me - results in the same error I run in during my first attempt.

Added your line to nginx stable:

2019/01/05 14:31:15 [emerg] 237#237: "listen" directive is not allowed here in /etc/httpd-custom.d/devilbox-custom.conf:18
httpd_1 | nginx: [emerg] "listen" directive is not allowed here in /etc/httpd-custom.d/devilbox-custom.conf:18
httpd_1 | watcherd: [2019-01-05 14:31:15] [ERR] TRIGGER failed: nginx -s stop
httpd_1 | watcherd: [2019-01-05 14:31:15] Using bash loop to watch for changes.
httpd_1 | 2019-01-05 14:31:18,084 INFO spawned: 'httpd' with pid 264
httpd_1 | 2019/01/05 14:31:18 [emerg] 264#264: "listen" directive is not allowed here in /etc/httpd-custom.d/devilbox-custom.conf:18
httpd_1 | nginx: [emerg] "listen" directive is not allowed here in /etc/httpd-custom.d/devilbox-custom.conf:18
httpd_1 | 2019-01-05 14:31:18,091 INFO exited: httpd (exit status 1; not expected)
httpd_1 | 2019-01-05 14:31:22,097 INFO spawned: 'httpd' with pid 297

...and looping

@cytopia
Copy link
Owner

cytopia commented Jan 5, 2019

@wolfwahl this setting does not go into cfg/nginx-stable|mainline but rather as a vhost-gen customization. See here for example: https://devilbox.readthedocs.io/en/latest/vhost-gen/example-add-subdomains.html#nginx

@wolfwahl
Copy link
Author

wolfwahl commented Jan 6, 2019

@cytopia cheers! Got it working - had to specify the server_name also.

Still get an error(?), but it serves h2 - so I'm fine.

httpd_1 | nginx: [emerg] a duplicate default server for 0.0.0.0:443 in /etc/httpd/vhost.d/yaspi.conf:3
httpd_1 | watcherd: [2019-01-06 09:34:01] [ERR] TRIGGER failed: nginx -s stop
httpd_1 | watcherd: [2019-01-06 09:34:01] Using bash loop to watch for changes.

@cytopia
Copy link
Owner

cytopia commented Jan 6, 2019

My bad, the example was shown for the default server and there can only always be one (which is used for the devilbox intranet on localhost itself). For all other vhosts, just omit the default_server:

    listen       443 ssl http2;

@cytopia
Copy link
Owner

cytopia commented Jan 6, 2019

@wolfwahl I've now made it the default for all SSL connections. Checkout the open PR: #462

It does not work on Apache 2.2 though (too old).

Also keep in mind that vhost-gen templates in cfg/vhost-gen/* have been adjusted, so if you have already customized templates in place (per project or globally), ensure to diff and update them accordingly.

cytopia added a commit to devilbox/docker-apache-2.4 that referenced this issue Jan 7, 2019
cytopia added a commit to devilbox/docker-nginx-mainline that referenced this issue Jan 7, 2019
cytopia added a commit to devilbox/docker-nginx-stable that referenced this issue Jan 7, 2019
cytopia added a commit to devilbox/docker-apache-2.4 that referenced this issue Jan 7, 2019
Refs cytopia/devilbox#431 Fix sourcing of global vhost-gen template
cytopia added a commit to devilbox/docker-nginx-stable that referenced this issue Jan 7, 2019
Refs cytopia/devilbox#431 Fix sourcing of global vhost-gen template
cytopia added a commit to devilbox/docker-nginx-mainline that referenced this issue Jan 7, 2019
Refs cytopia/devilbox#431 Fix sourcing of global vhost-gen template
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants