Skip to content

Digitalocean step by step guide to nginx configuration

Solved Configure
36 2 15.1k 1
  • @justoverclock If the app is listening on 8080, which it typically would, then no, leave it alone. Are the endpoints intended to be public ? Typically, these aren’t accessible via nginx

    wrote on last edited by
    #23

    @phenomlab if now i try to login, the endpoint of my api doesn’t work because of mixed content

    Mixed Content: The page at 'https://vfgest.it/' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://MYSERVERIP:3030/api/login'. This request has been blocked; the content must be served over HTTPS.
    
  • @phenomlab if now i try to login, the endpoint of my api doesn’t work because of mixed content

    Mixed Content: The page at 'https://vfgest.it/' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://MYSERVERIP:3030/api/login'. This request has been blocked; the content must be served over HTTPS.
    
    wrote on last edited by
    #24

    @justoverclock Yes, that’s expected. You should change your endpoint so it works over https otherwise it won’t be secure, and is then subject to eavesdropping as the traffic is being sent in clear text. From a security standpoint, this is an absolute no.

  • @justoverclock Yes, that’s expected. You should change your endpoint so it works over https otherwise it won’t be secure, and is then subject to eavesdropping as the traffic is being sent in clear text. From a security standpoint, this is an absolute no.

    wrote on last edited by
    #25

    @phenomlab ok, so i can add https, can i leave the ip or i need to add vfgest.it:3030?

  • @phenomlab ok, so i can add https, can i leave the ip or i need to add vfgest.it:3030?

    wrote on last edited by
    #26

    @justoverclock You can use either, but if the API is not meant to be exposed publicly, and should only be accessed by the app itself, then you should use 127.0.0.1. Ultimately, the design is up to you.

  • @justoverclock You can use either, but if the API is not meant to be exposed publicly, and should only be accessed by the app itself, then you should use 127.0.0.1. Ultimately, the design is up to you.

    wrote on last edited by
    #27

    @phenomlab well, i’ve learned something new, no its a private crm developed by me, so no external use 🙂

  • @phenomlab well, i’ve learned something new, no its a private crm developed by me, so no external use 🙂

    wrote on last edited by phenomlab
    #28

    @justoverclock Exactly - that’s why I asked 🙂 You won’t be exposing the API then. Any issues, let me know.

  • @justoverclock Exactly - that’s why I asked 🙂 You won’t be exposing the API then. Any issues, let me know.

    wrote on last edited by
    #29

    @phenomlab ok i’ll try later when people are not using the crm :P, and i’ll post here the result 😄

  • @phenomlab ok i’ll try later when people are not using the crm :P, and i’ll post here the result 😄

    wrote on last edited by
    #30

    @justoverclock No problems.

  • phenomlab phenomlab has marked this topic as solved on
  • phenomlab phenomlab referenced this topic on
  • @justoverclock No problems.

    wrote on last edited by justoverclock
    #31

    @phenomlab its odd but doesn’t work if i use https://vfgest.it:3030 or https://SERVERIP:3030 or https://127.0.0.1:3030

    must be something related to proxy…because server and client are on the same server…but works if i restore all to previous unsecure http connection

  • @phenomlab its odd but doesn’t work if i use https://vfgest.it:3030 or https://SERVERIP:3030 or https://127.0.0.1:3030

    must be something related to proxy…because server and client are on the same server…but works if i restore all to previous unsecure http connection

    wrote on last edited by
    #32

    @justoverclock i’ve found an article that says
    To resolve your issue you can setup nginx to proxy your http backend urls via https. With nginx server you will need to call your api like https://your_domain/api/some_path and nginx will proxy your request to api host, that you will set in config

    so my server actually is on port 3030, what should i do?

    thx!

  • @justoverclock i’ve found an article that says
    To resolve your issue you can setup nginx to proxy your http backend urls via https. With nginx server you will need to call your api like https://your_domain/api/some_path and nginx will proxy your request to api host, that you will set in config

    so my server actually is on port 3030, what should i do?

    thx!

    wrote on last edited by
    #33

    @justoverclock ok i’ve found the solution by myself watching your files…

    -i’ve created a subdomain

    • a new server blocks that proxy requests to the backend endpoint
    • secured with certbot

    all works fine 🍕

  • @justoverclock ok i’ve found the solution by myself watching your files…

    -i’ve created a subdomain

    • a new server blocks that proxy requests to the backend endpoint
    • secured with certbot

    all works fine 🍕

    wrote on last edited by
    #34

    @justoverclock Beat me to it ! I was going to say that you could add another server block to the existing configuration, so for example

    location /api {
                    proxy_set_header X-Real-IP $remote_addr;
                    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                    proxy_set_header Host $http_host;
                    proxy_set_header X-NginX-Proxy true;
    
                    proxy_pass http://127.0.0.1:3030/;
                    proxy_redirect off;
    
                    # Socket.IO Support
                    proxy_http_version 1.1;
                    proxy_set_header Upgrade $http_upgrade;
                    proxy_set_header Connection "upgrade";
    }
  • @justoverclock Beat me to it ! I was going to say that you could add another server block to the existing configuration, so for example

    location /api {
                    proxy_set_header X-Real-IP $remote_addr;
                    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                    proxy_set_header Host $http_host;
                    proxy_set_header X-NginX-Proxy true;
    
                    proxy_pass http://127.0.0.1:3030/;
                    proxy_redirect off;
    
                    # Socket.IO Support
                    proxy_http_version 1.1;
                    proxy_set_header Upgrade $http_upgrade;
                    proxy_set_header Connection "upgrade";
    }
    wrote on last edited by
    #35

    @phenomlab 😛 i’m learning ahahahah 🙏

  • @phenomlab 😛 i’m learning ahahahah 🙏

    wrote on last edited by
    #36

    @justoverclock said in Digitalocean step by step guide to nginx configuration:

    i’m learning

    And that’s the whole point of this site 🙂 If you don’t learn anything, you gain nothing.


Did this solution help you?
Did you find the suggested solution useful? Support 💗 Sudonix with a coffee ☕
If your organisation needs deeper expertise around infrastructure, security, or technology leadership, learn more about Phenomlab Ltd. Many of the deeper technical guides behind Sudonix are published there.

Related Topics
  • configure ghost and wordpress combo

    Moved Solved WordPress ghost wordpress nginx
    9
    7 Votes
    9 Posts
    3k Views
    phenomlab
    @Madchatthew I’d always post for the reasons I stated above. It’s useful information and could save someone else the headache.
  • 4 Votes
    8 Posts
    5k Views
    WesleyMoura
    @phenomlab Sorry to delay in responding, yes as i mentioned above, i had to remove my redis from docker and reinstall a new image with this command docker run --name=redis -p 127.0.0.1:6379:6379 -d -t redis:alpine and now when i test my ip and port on https://www.yougetsignal.com/tools/open-ports/ the status of my redis port is closed. I think which to configure firewall in droplet digital ocean is a good idea too, and i will configure soon. Thanks for the help!
  • Virtualmin Setup DigitalOcean

    Solved Customisation virtualmin digitalocean
    26
    9 Votes
    26 Posts
    13k Views
    phenomlab
    @Hari said in Virtualmin Setup DigitalOcean: i have felt it is very hard to manage Virtualmin the settings are confusing It’s a bit of a learning curve, admittedly, but very powerful and easy to use provided you understand the implications of what you are doing. For example, moving a VirtualMin server to subserver and then back again without changing underlying components that rely on the correct placement of the server, of course it will no longer work.
  • speed up my DigitalOcean droplet - Virtualmin

    Solved Configure digitalocean virtualmin
    10
    4 Votes
    10 Posts
    3k Views
    Hari
    @phenomlab thanks for sharing, after four or five months I will migrate to DO 2 or 4gb RAM droplet.
  • how to change flarum configuration from apache to nginx?

    Solved Configure flarum
    3
    0 Votes
    3 Posts
    1k Views
    phenomlab
    See https://sudonix.com/topic/226/issues-getting-flarum-to-work-on-new-host/28?_=1645013723672
  • nginx seo urls

    Solved Configure
    15
    3 Votes
    15 Posts
    6k Views
    phenomlab
    @riekmedia that looks fine to me
  • is my DMARC configured correctly?

    Solved Configure
    3
    2
    3 Votes
    3 Posts
    2k Views
    Hari
    @phenomlab said in is my DMARC configured correctly?: you’ll get one from every domain that receives email from yours. Today I have received another mail from outlook DMARC, i was referring to your reply again and found it very helpful/informative. thanks again. I wish sudonix 100 more great years ahead!
  • help me configuring cron job for fof/sitemap - flarum

    Solved Configure
    36
    18 Votes
    36 Posts
    13k Views
    DownPW
    you are too fast