drogon icon indicating copy to clipboard operation
drogon copied to clipboard

adding example 'webserver reverse proxy'

Open prothegee opened this issue 1 year ago • 11 comments

drogon framework example: webserver reverse proxy

NOTE:

this example show how to use drogon as webserver and using reverse proxy

steps:

  • add these:

    127.0.0.1   localhost.com
    127.0.0.1   api.localhost.com
    127.0.0.1   admin.localhost.com
    127.0.0.1   www.localhost.com
    

    to

    • linux debian base location:

      • /etc/hosts:
    • windows base location:

      • C:\Windows\System32\drivers\etc\hosts:

  • make it sure drogon config is already installed on your machine environment

  • build this project, you can use build-debug-linux.sh on linux environment

  • launch:

    • terminal:

      • go to ./bin directory and run each of these:
        • ./drogon_server
        • ./backend_api
        • ./backend_www
    • open your browser:

      • go to:
        • http://www.localhost.com:9999:

          • this will redirect to http://localhost.com:9999
        • http://localhost.com:9999:

          • will show example message and which port is called
        • http://api.localhost.com:9999:

          • will show json message from which port
        • http://api.localhost.com:9999/test:

          • will show json message from /test endpoint/path and show which port is called


preview result example



end of readme

prothegee avatar May 24 '24 09:05 prothegee

@prothegee Thanks so much for your patch. I noticed that there is currently a reverse proxy example in the example directory. Is your example different from it? Can you consider submitting your modifications based on the original example?

an-tao avatar May 25 '24 13:05 an-tao

drogon framework is more like http framework arsenal in my mind, dev user can leverage their existence knowledge to do what their want from drogon framework.

back when example of 'simple_reverse_proxy' exists, I had something in mind to use drogon framework as my core server rather than use nginx or h2o.

back then, I can't figure it out how extend this framework as webserver since it was early year I used drogon framework, so either I ended up using drogon as one backend in one machine using port 80 & 443 or I mix it up with another webserver.

and yet now I could figure it out how to extend as core server rather than use another webserver/server proxy.


my appoligies to not provide more information as the core purpose of my pr.


the keyword of 'simple example' and 'example' is already different.

to consider as modification from original example, offcourse I believe it's possible.. but the keyword 'simple_reverse_proxy' thou...


perhaps I could provide as 'reverse_proxy', 'webserver_reverse_proxy', or extend 'simple_reverse_proxy' then decide does this related pr is suitable to be merge or not, requesting permission from you/maintainer.


question: what does error mean on:

  • https://github.com/drogonframework/drogon/actions/runs/9226894788/job/25410965274?pr=2035
  • https://github.com/drogonframework/drogon/actions/runs/9226894791/job/25410965146?pr=2035

never use this kind of workflow, and how to fix those error by the way?

prothegee avatar May 25 '24 14:05 prothegee

@prothegee Thank you for your patient explanation, I will accept this PR after some code review

an-tao avatar May 26 '24 11:05 an-tao

I have a concern about creating large examples.

As drogon release new version, old examples may have compatiblility issues. It's hard to say that example authors will keep maintaining them. At last the maintaining work falls on us. I personally don't feel like to maintain something I don't use at all...

I suggest we create a standalone repo for large examples. At least it won't affect the main project.

hwc0919 avatar May 30 '24 05:05 hwc0919

Sure, something like core and extras is a good idea.

rbugajewski avatar May 30 '24 07:05 rbugajewski

I had related closed issue with this, [HttpAppFramework / HttpClientPtr ] can't change/set (ssl key, cert, & configuration) after/on plugin

since currently drogon can't change/set included key, cert, & conf on the run, this example proly useless, unless using wildcard cert key

I think I'm gonna kept it on my branch fork repo or just let it dangle in that closed issue for historical search

prothegee avatar May 30 '24 08:05 prothegee

I have swiftly sifted through it and I like the idea of the ReverseProxy plugin.

If we consider merging this, then I'll try to do a full review.

Mis1eader-dev avatar May 30 '24 15:05 Mis1eader-dev

Based on the above discussion, I think creating a new drogon-examples repo is a solution acceptable to everyone. I will do it ASAP.

an-tao avatar May 31 '24 03:05 an-tao

The Play framework has a repo for each example. That's one approach.

On Thu, May 30, 2024, 8:00 PM An Tao @.***> wrote:

Based on the above discussion, I think creating a new drogon-examples repo is a solution acceptable to everyone. I will do it ASAP.

— Reply to this email directly, view it on GitHub https://github.com/drogonframework/drogon/pull/2035#issuecomment-2141149836, or unsubscribe https://github.com/notifications/unsubscribe-auth/BBZFRV52MWSNTYXAS5R4GR3ZE7RVVAVCNFSM6AAAAABIHG4D4GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNBRGE2DSOBTGY . You are receiving this because you are subscribed to this thread.Message ID: @.***>

albaropereyra22 avatar May 31 '24 09:05 albaropereyra22

The Play framework has a repo for each example. That's one approach.

I vote for this

hwc0919 avatar May 31 '24 10:05 hwc0919

I think one repo per example is too much, and will only increase burden on the maintainers, but if this organization would be bigger, I would also prefer this approach.

rbugajewski avatar Jun 03 '24 06:06 rbugajewski