x64architecture / wnmp

An easy Nginx, MariaDB and PHP environment for Windows.
https://wnmp.x64architecture.com
GNU General Public License v3.0
509 stars 110 forks source link

Multiple local domains (and maybe configurable list in the GUI) #110

Open chang-zhao opened 5 years ago

chang-zhao commented 5 years ago

1. Often users would like to add another local domain (not just one "localhost").

For that, it could be good to provide a sample config.

For example, in nginx.conf, after closing HTTPS server section, add

include domains\*.conf;

Make dir "domains" in "conf". Place there "phpmyadmin.conf" with server declaration, like

server {
listen 127.0.0.1:80;
server_name phpmyadmin;
allow 127.0.0.1; # Limit remote access which is a security risk
deny all; # Limit remote access which is a security risk

and so on. As for the "root" directive, it could be written on install, or user could be instructed how to adjust it. Likewise, deal with adding "127.0.0.1 phpmyadmin" to hosts file, and perhaps a GUI control to edit hosts file.

This way novice users would have great help in setup.

2. Then maybe it's useful to add a configurable shortcut menu to that "localhost" link in GUI. For example, WNMP could read/write in its config file something like

[links]
localhost, http://localhost
phpMyAdmin, https://phpmyadmin

(label, address)

Thank you again, Kurt!

chang-zhao commented 5 years ago

About root directive, it's easy to do this way:

In the html section -

    map $host $root {
    default *our real web root directory here*;
    }
    root $root;

This is enough for the localhost server. For additional servers use this code:

    server_name ~^(?<domain>phpmyadmin)$;
    root    $root/$domain;

where instead of phpmyadmin can be any other name; they all will be mapped to a dir with such name in the root web folder ("html" or something).

The rest of individual "server" section could be the same or different, depending on the needs of particular site.

mittus commented 5 years ago

I am against the output nginx settings on the wnmp panel, becouse Nginx can be used for other purposes. I like the wnmp, because I can customize it how I want, without depend the interface.

chang-zhao commented 5 years ago

I am against the output nginx settings on the wnmp panel, becouse Nginx can be used for other purposes. I like the wnmp, because I can customize it how I want, without depend the interface.

I see your point. What I'm proposing is that users could add quick links, it's like bookmarks right on the panel. If you don't want it you don't add it.

Though maybe it's not very important.

mittus commented 5 years ago

I see your point. What I'm proposing is that users could add quick links, it's like bookmarks right on the panel. If you don't want it you don't add it.

You gave very simple example. Users can use one config with unlimited local websites:

    server_name ~^(?<domain>phpmyadmin)$;
    root    $root/$domain;
chang-zhao commented 5 years ago

You gave very simple example. Users can use one config with unlimited local websites:

Yes. And for different servers, there may be the need for different configs - depending on the software (engines) installed; for example, one server has Joomla, another DokuWiki etc., they all have some fine-tuning directives.

Though maybe you are right and such configs shouldn't be bundled with the WNMP; it's better to describe such configs in the desriptions or WNMP Wiki, right?

chang-zhao commented 5 years ago

OK, I have added Custom NGINX configurations page to the Wiki.

And the option to add custom bookmarks to WNMP maybe isn't worth the time & efforts.

However, see the note in "Custom NGINX configurations" about force redirect for phpMyAdmin. I experienced that "no-login" bug myself, so I suggest to add that force redirect to WNMP config.

I don't mind if this issue would be closed.

Thanks Kurt and all the Open Source guys out there!