Cloudron makes it easy to run web apps like WordPress, Nextcloud, GitLab on your server. Find out more or install now.


Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Bookmarks
  • Search
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

Cloudron Forum

Apps | Demo | Docs | Install
  1. Cloudron Forum
  2. Support
  3. Where can I put custom nginx conf that won't be overwritten?

Where can I put custom nginx conf that won't be overwritten?

Scheduled Pinned Locked Moved Solved Support
reverseproxynginx
21 Posts 5 Posters 3.7k Views 5 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • kaxlineK Offline
    kaxlineK Offline
    kaxline
    wrote on last edited by girish
    #1

    I'm trying to put my Ghost blog at the /blog route of my domain, while my static site is served from the / root via Surfer.

    I've got this config at the bottom of the Cloudron-generated .conf file for the Ghost app:

    location /blog {
         proxy_pass http://172.18.17.251:2368;
    }
    
    location / {
          proxy_pass http://172.18.17.70:3000;
    }
    

    Which gets overwritten quite often, at least once a day. It there a better way to do this routing or a different file to store the config in so that it doesn't get overwritten?

    Or do I need to setup a cron to just place it back in whenever it gets overwritten?

    I've read through a few posts here about nginx proxying but its hard to figure out the best method from what's been posted.

    Thanks!

    girishG robiR 2 Replies Last reply
    0
    • nebulonN Offline
      nebulonN Offline
      nebulon
      Staff
      wrote on last edited by
      #2

      As you said, this will eventually get overwritten and currently none of the apps are packaged in a way to allow them to run on subpaths of other apps. Usually apps require this knowledge for link sharing or links in transactional emails, so I guess you will hit other issues anyways.

      I think the current only option is, to put a html meta redirect file at /blog which redirects to the ghost domain.

      kaxlineK robiR 2 Replies Last reply
      1
      • nebulonN nebulon marked this topic as a question on
      • nebulonN nebulon

        As you said, this will eventually get overwritten and currently none of the apps are packaged in a way to allow them to run on subpaths of other apps. Usually apps require this knowledge for link sharing or links in transactional emails, so I guess you will hit other issues anyways.

        I think the current only option is, to put a html meta redirect file at /blog which redirects to the ghost domain.

        kaxlineK Offline
        kaxlineK Offline
        kaxline
        wrote on last edited by
        #3

        @nebulon OK thanks for this. Won't the redirect have to point to a different domain or subdomain though? I need them to share a root domain in order for the blog traffic to contribute to the static site's SEO.

        https://re-public.io --> Surfer, static
        https://re-public.io/blog --> Ghost

        girishG 1 Reply Last reply
        0
        • nebulonN nebulon

          As you said, this will eventually get overwritten and currently none of the apps are packaged in a way to allow them to run on subpaths of other apps. Usually apps require this knowledge for link sharing or links in transactional emails, so I guess you will hit other issues anyways.

          I think the current only option is, to put a html meta redirect file at /blog which redirects to the ghost domain.

          robiR Offline
          robiR Offline
          robi
          wrote on last edited by
          #4

          @nebulon said in Where can I put custom nginx conf that won't be overwritten?:

          I think the current only option is, to put a html meta redirect file at /blog which redirects to the ghost domain.

          That's app level, what about host level?

          Conscious tech

          1 Reply Last reply
          1
          • kaxlineK kaxline

            I'm trying to put my Ghost blog at the /blog route of my domain, while my static site is served from the / root via Surfer.

            I've got this config at the bottom of the Cloudron-generated .conf file for the Ghost app:

            location /blog {
                 proxy_pass http://172.18.17.251:2368;
            }
            
            location / {
                  proxy_pass http://172.18.17.70:3000;
            }
            

            Which gets overwritten quite often, at least once a day. It there a better way to do this routing or a different file to store the config in so that it doesn't get overwritten?

            Or do I need to setup a cron to just place it back in whenever it gets overwritten?

            I've read through a few posts here about nginx proxying but its hard to figure out the best method from what's been posted.

            Thanks!

            girishG Offline
            girishG Offline
            girish
            Staff
            wrote on last edited by
            #5

            @kaxline said in Where can I put custom nginx conf that won't be overwritten?:

            Which gets overwritten quite often, at least once a day.

            This shouldn't happen. The nginx config is only overwritten on a Cloudron update (and that too only if the update has any changes to nginx configuration). App updates also don't re-generate the nginx file. Maybe we have a bug somewhere but I have put some logs in my dev setup to see if this is reproducible here and what's causing this.

            Note that every time, you do something that needs the app's container to be re-created, the nginx has to be re-generated. This is done because of the proxy_pass referencing the container by IP address. A container is recreated when you change it's location, email address, change storage, portbindings etc.

            kaxlineK 1 Reply Last reply
            1
            • kaxlineK kaxline

              @nebulon OK thanks for this. Won't the redirect have to point to a different domain or subdomain though? I need them to share a root domain in order for the blog traffic to contribute to the static site's SEO.

              https://re-public.io --> Surfer, static
              https://re-public.io/blog --> Ghost

              girishG Offline
              girishG Offline
              girish
              Staff
              wrote on last edited by
              #6

              @kaxline said in Where can I put custom nginx conf that won't be overwritten?:

              I need them to share a root domain in order for the blog traffic to contribute to the static site's SEO.

              Not a SEO expert, so.. Is this a valid assumption that putting things in subdomains helps with SEO ?

              (If it's a hypothesis, I guess that's fine too. Maybe we can try to add something on Cloudron side to allow subpaths to redirect to another app but this has security implications we have to think through like cookies/sessions/email notifications etc).

              kaxlineK 1 Reply Last reply
              1
              • girishG girish

                @kaxline said in Where can I put custom nginx conf that won't be overwritten?:

                Which gets overwritten quite often, at least once a day.

                This shouldn't happen. The nginx config is only overwritten on a Cloudron update (and that too only if the update has any changes to nginx configuration). App updates also don't re-generate the nginx file. Maybe we have a bug somewhere but I have put some logs in my dev setup to see if this is reproducible here and what's causing this.

                Note that every time, you do something that needs the app's container to be re-created, the nginx has to be re-generated. This is done because of the proxy_pass referencing the container by IP address. A container is recreated when you change it's location, email address, change storage, portbindings etc.

                kaxlineK Offline
                kaxlineK Offline
                kaxline
                wrote on last edited by
                #7

                @girish OK, interesting. It's happening twice a day at the exact same times. 5am and 5pm PT. Here's a screenshot from Uptime Kuma.

                Screen Shot 2022-03-29 at 5.04.42 AM.png

                1 Reply Last reply
                0
                • girishG girish

                  @kaxline said in Where can I put custom nginx conf that won't be overwritten?:

                  I need them to share a root domain in order for the blog traffic to contribute to the static site's SEO.

                  Not a SEO expert, so.. Is this a valid assumption that putting things in subdomains helps with SEO ?

                  (If it's a hypothesis, I guess that's fine too. Maybe we can try to add something on Cloudron side to allow subpaths to redirect to another app but this has security implications we have to think through like cookies/sessions/email notifications etc).

                  kaxlineK Offline
                  kaxlineK Offline
                  kaxline
                  wrote on last edited by
                  #8

                  @girish Seems to be the consensus, though Google SEO is an ever-changing black box:

                  https://chrisberkley.com/blog/subdomains-for-seo/

                  I think it makes sense since many sites have wildly different functionality and content based on subdomains.

                  1 Reply Last reply
                  0
                  • kaxlineK kaxline

                    I'm trying to put my Ghost blog at the /blog route of my domain, while my static site is served from the / root via Surfer.

                    I've got this config at the bottom of the Cloudron-generated .conf file for the Ghost app:

                    location /blog {
                         proxy_pass http://172.18.17.251:2368;
                    }
                    
                    location / {
                          proxy_pass http://172.18.17.70:3000;
                    }
                    

                    Which gets overwritten quite often, at least once a day. It there a better way to do this routing or a different file to store the config in so that it doesn't get overwritten?

                    Or do I need to setup a cron to just place it back in whenever it gets overwritten?

                    I've read through a few posts here about nginx proxying but its hard to figure out the best method from what's been posted.

                    Thanks!

                    robiR Offline
                    robiR Offline
                    robi
                    wrote on last edited by
                    #9

                    @kaxline have you tried separating out your changes out of the /etc/nginx/applications dir config file and into something like the sites-available dir in a separate config file?

                    Cloudron doesn't use that dir so it won't be overwriting it with any app updates.

                    Conscious tech

                    kaxlineK 1 Reply Last reply
                    1
                    • robiR robi

                      @kaxline have you tried separating out your changes out of the /etc/nginx/applications dir config file and into something like the sites-available dir in a separate config file?

                      Cloudron doesn't use that dir so it won't be overwriting it with any app updates.

                      kaxlineK Offline
                      kaxlineK Offline
                      kaxline
                      wrote on last edited by
                      #10

                      @robi I haven't tried that because I'm not sure where to put it in order to have it overwrite the default Cloudron configs. Any suggestions on that? Thanks!

                      girishG robiR 2 Replies Last reply
                      0
                      • kaxlineK kaxline

                        @robi I haven't tried that because I'm not sure where to put it in order to have it overwrite the default Cloudron configs. Any suggestions on that? Thanks!

                        girishG Offline
                        girishG Offline
                        girish
                        Staff
                        wrote on last edited by
                        #11

                        @kaxline I think to properly support this, we can look into this for the next release. For the moment, I am still perplexed why those nginx configs are being overwritten everyday. I am not able to reproduce this here atleast.

                        Can you please try this:

                        • Edit some random nginx config file
                        • Add a dummy comment
                        • Can you report back tomorrow if that comment is still there? Or did it disappear?
                        kaxlineK 1 Reply Last reply
                        2
                        • kaxlineK kaxline

                          @robi I haven't tried that because I'm not sure where to put it in order to have it overwrite the default Cloudron configs. Any suggestions on that? Thanks!

                          robiR Offline
                          robiR Offline
                          robi
                          wrote on last edited by
                          #12

                          @kaxline there should be an nginx doc somewhere that describes the order in which it loads configs from different directories.

                          Conscious tech

                          1 Reply Last reply
                          1
                          • scookeS Offline
                            scookeS Offline
                            scooke
                            wrote on last edited by
                            #13

                            Rather than trying to get Docker to do something it isn't usually tasked with doing (or perhaps within the Cloudron system), do these posts offer a possible alternative?:

                            https://cloak.ist/blog/how-to-put-a-ghost-blog-at-a-subdirectory-using-cloudflare-workers/

                            https://www.indiehackers.com/product/img-vision/ghost-blog-is-now-hosted-on-main-domain--M6Gt3CSAp3nIFeZKOC-

                            A life lived in fear is a life half-lived

                            kaxlineK 1 Reply Last reply
                            1
                            • girishG girish

                              @kaxline I think to properly support this, we can look into this for the next release. For the moment, I am still perplexed why those nginx configs are being overwritten everyday. I am not able to reproduce this here atleast.

                              Can you please try this:

                              • Edit some random nginx config file
                              • Add a dummy comment
                              • Can you report back tomorrow if that comment is still there? Or did it disappear?
                              kaxlineK Offline
                              kaxlineK Offline
                              kaxline
                              wrote on last edited by
                              #14

                              @girish OK, I chose a couple of the other app configs and added a comment. They were overwritten along with the Ghost config I originally was asking about. Any thoughts? Anything significant about the 5am/5pm PT time? Want me to test anything else? Send you some logs?

                              girishG 1 Reply Last reply
                              0
                              • scookeS scooke

                                Rather than trying to get Docker to do something it isn't usually tasked with doing (or perhaps within the Cloudron system), do these posts offer a possible alternative?:

                                https://cloak.ist/blog/how-to-put-a-ghost-blog-at-a-subdirectory-using-cloudflare-workers/

                                https://www.indiehackers.com/product/img-vision/ghost-blog-is-now-hosted-on-main-domain--M6Gt3CSAp3nIFeZKOC-

                                kaxlineK Offline
                                kaxlineK Offline
                                kaxline
                                wrote on last edited by
                                #15

                                @scooke Yes! Thank you! I was looking at how to do this with Cloudflare right off the bat but couldn't find how to do it. Working now!

                                I would say this is less about Docker and more about Nginx. It would be nice to easily route subdirectory paths to different Cloudron apps via Nginx. Maybe in the UI there's a way to add a directory path in the Location panel.

                                Thanks again!

                                girishG 1 Reply Last reply
                                1
                                • kaxlineK kaxline

                                  @girish OK, I chose a couple of the other app configs and added a comment. They were overwritten along with the Ghost config I originally was asking about. Any thoughts? Anything significant about the 5am/5pm PT time? Want me to test anything else? Send you some logs?

                                  girishG Offline
                                  girishG Offline
                                  girish
                                  Staff
                                  wrote on last edited by
                                  #16

                                  @kaxline To give some update here, I put the comment in some of our internal cloudrons. I can confirm that in some of them the nginx configs are overwritten. I will investigate as to why.

                                  1 Reply Last reply
                                  0
                                  • robiR Offline
                                    robiR Offline
                                    robi
                                    wrote on last edited by
                                    #17

                                    One can use the include /path/...; command for additional appX.conf files

                                    I believe, you could use this configuration:

                                    server {
                                        server_name example.com;
                                        listen      [::]:80;
                                        listen      80;
                                    
                                        include /path/to/applications/*/nginx.conf;
                                    }
                                    

                                    and then in each application's directory configure the redirection like this:

                                    location    /app1 {
                                        proxy_pass  http://app1;
                                        proxy_http_version 1.1;
                                        proxy_set_header Upgrade $http_upgrade;
                                        proxy_set_header Connection "upgrade";
                                        proxy_set_header Host $http_host;
                                        proxy_set_header X-Forwarded-Proto $scheme;
                                        proxy_set_header X-Forwarded-For $remote_addr;
                                        proxy_set_header X-Forwarded-Port $server_port;
                                        proxy_set_header X-Request-Start $msec;
                                    }
                                    

                                    Conscious tech

                                    1 Reply Last reply
                                    1
                                    • kaxlineK kaxline

                                      @scooke Yes! Thank you! I was looking at how to do this with Cloudflare right off the bat but couldn't find how to do it. Working now!

                                      I would say this is less about Docker and more about Nginx. It would be nice to easily route subdirectory paths to different Cloudron apps via Nginx. Maybe in the UI there's a way to add a directory path in the Location panel.

                                      Thanks again!

                                      girishG Offline
                                      girishG Offline
                                      girish
                                      Staff
                                      wrote on last edited by
                                      #18

                                      @kaxline I found the issue! Can you please try this one-liner - https://git.cloudron.io/cloudron/box/-/commit/6839ff4cf60cb725d224619ee55bcf066a496a12 . The file to edit is /home/yellowtent/box/src/reverseproxy.js . After that, the nginx configs will not get overwritten everyday.

                                      kaxlineK 1 Reply Last reply
                                      2
                                      • girishG girish

                                        @kaxline I found the issue! Can you please try this one-liner - https://git.cloudron.io/cloudron/box/-/commit/6839ff4cf60cb725d224619ee55bcf066a496a12 . The file to edit is /home/yellowtent/box/src/reverseproxy.js . After that, the nginx configs will not get overwritten everyday.

                                        kaxlineK Offline
                                        kaxlineK Offline
                                        kaxline
                                        wrote on last edited by
                                        #19

                                        @girish I ended up going with a Cloudflare script, which feels a little cleaner for now. I'll try this when I revisit the issue. Thanks for all your help!

                                        robiR 1 Reply Last reply
                                        1
                                        • kaxlineK kaxline

                                          @girish I ended up going with a Cloudflare script, which feels a little cleaner for now. I'll try this when I revisit the issue. Thanks for all your help!

                                          robiR Offline
                                          robiR Offline
                                          robi
                                          wrote on last edited by
                                          #20

                                          @kaxline can you kindly share your script?

                                          We have other Cloudflare users here who may benefit from your experience. 😄

                                          Conscious tech

                                          kaxlineK 1 Reply Last reply
                                          2
                                          • girishG girish has marked this topic as solved on
                                          • P Prinzhorn referenced this topic on
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Bookmarks
                                          • Search