Nginx subdomains config

    • OMV 3.x
    • Nginx subdomains config

      Hello everyone.
      On my OMV I install nginx plugin.
      I have my domain fo example mydomain.com


      On nginx I create several websites: nextcloud, wordpress and standard www webpage

      nextcloud uses port 500
      wordpress uses port 600
      and some other page on port 700

      These ports are redirect on my router
      Everything works fine when I insert mydomain.com:500 or mydomain.com:600

      I would like to reconfigure nginx to work like that:
      When I insert oc.mydomain.com will open my nextcloud website
      When I insert blog.mydomain.com will open my wordpress website
      When I insert mydomain.com its work becouse it is redirect on my ruter from port 80 to 700
    • Please show an example, i'll try to do for shellinaBox and is not possible ( at least on dynu.net):
      Images
      • 1.jpg

        121.19 kB, 1,171×499, viewed 293 times
      OMV 3.0.96 x64 on a HP T510, 16GB CF as Boot Disk & 32GB SSD 2,5" disk for Data, 4 GB RAM, CPU VIA EDEN X2 U4200 is x64 at 1GHz

      Post: HPT510 SlimNAS ; HOWTO Install Pi-Hole ; HOWTO install MLDonkey ; HOHTO Install ZFS-Plugin ; OMV_OldGUI ; ShellinaBOX ;
      Dockers: MLDonkey ; PiHole ;
      Videos: @TechnoDadLife
    • i think its right. and you must a setup in your nginx-plugin with a namebased surfer with the full name for example shell.dynu.net
      But by the way... i would not use a shell over the internet ;)
      omv 4.0.19 | 64 bit | omvextrasorg 4.1.2 | kernel 4.14
      used plugins: nginx | mysql | docker-gui |rsnapshot | antivirus | apt tool | letsEncrypt |
      used other: netxtcloud | logitechmediaserver | emby
    • Hello again.
      I made both settings but somethings goes wrong and still not working:
      forum.openmediavault.org/index…ostname-Nginx-Proxy-pass/
      http://blog.manugarri.com/how-to-easily-set-up-subdomain-routing-in-nginx/


      Files wasn't exist before, now they looks like below:

      /etc/nginx/sites-available/multi_host
      #defaultweb server { server_name mydomain.com; listen [::]:80; location / { proxy_pass http://localhost:700/; } } #defaultweb server { server_name mydomain.com; listen [::]:443; location / { proxy_pass http://localhost:743/; } } #nextcloud server { server_name oc.mydomain.com; listen [::]:80; location / { proxy_pass http://localhost:500/; proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Server $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } #nextcloud_https server { server_name oc.mydomain.com; listen [::]:443; location / { proxy_pass http://localhost:543/; proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Server $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } #blog server { server_name blog.mydomain.com; listen [::]:80; location / { proxy_pass_header X-Transmission-Session-Id; proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Server $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://localhost:600; } }

      /etc/nginx/sites-enabled/default

      server { listen 80; server_name mydomain.com; location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header Host $host; proxy_pass http://127.0.0.1:580; } } server { listen 443; server_name mydomain.com; location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header Host $host; proxy_pass http://127.0.0.1:543; } } server { listen 80; server_name oc.mydomain.com; location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header Host $host; proxy_pass http://127.0.0.1:8443; } } server { listen 443; server_name oc.mydomain.com; location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header Host $host; proxy_pass http://127.0.0.1:8443; } } server { listen 80; server_name blog.mydomain.com; location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header Host $host; proxy_pass http://127.0.0.1:680; } }

      /etc/nginx/sites-enabled/multi_host


      mydomain.com is not my local domain in LAN but this is some webpage addres available in international DNS servers.


      Please help what im doing wrong.
    • Hi, you must update your DNS records with your DNS provider to point subdomain.domain.com to your dynamic/static public IP.

      Without this DNS info updated, no computer knows how to find the IP of your webserver.

      You'll have to reformat your nginx conf files for me to look at them... sorry.
      :cursing: Intel NUC Kit DE3815TYKHE My NAS build / ARK
      Atom E3815 1.46GHz4GB RAM • 1TB SSHD • 4GB eMMC
      OMV 3.x | OMV-Extras | Flash Memory | Pi-hole

      RPi/3 №1: LibreElec 8.xRPi/3 №2: SickRage, PiVPN, noip2
    • DNS records was update earlier.
      A record mydomain.com -> my public IP
      CNAME record oc.mydomain.com -> mydomain.com
      CNAME record blog.mydomain.com -> mydomain.com

      Now when I open mydomain.com default is opening web page listening on port 700 because in my router there is redirect port 80 to 700.
      When I open blog.mydomain.com or oc.mydomain.com also open webpage listen on 700 port.
      Files looks like below but after I create these files I cannot login to OMV web browser cannot establish security connection in IE and FF.

      Source Code

      1. #defaultweb server
      2. {
      3. server_name mydomain.com;
      4. listen [::]:80;
      5. location / { proxy_pass http://localhost:700/;}
      6. }
      7. #defaultweb server
      8. {
      9. server_name mydomain.com;
      10. listen [::]:443;
      11. location / { proxy_pass http://localhost:743/; }
      12. }
      13. #nextcloud server
      14. {
      15. server_name oc.mydomain.com;
      16. listen [::]:80; location / { proxy_pass http://localhost:500/;
      17. proxy_set_header X-Forwarded-Host $host;
      18. proxy_set_header X-Forwarded-Server $host;
      19. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; }
      20. }
      21. #nextcloud_https server
      22. {
      23. server_name oc.mydomain.com; listen [::]:443;
      24. location / { proxy_pass http://localhost:543/;
      25. proxy_set_header X-Forwarded-Host $host;
      26. proxy_set_header X-Forwarded-Server $host;
      27. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; }
      28. }
      29. #blog server
      30. {
      31. server_name blog.mydomain.com;
      32. listen [::]:80; location / { proxy_pass_header X-Transmission-Session-Id;
      33. proxy_set_header X-Forwarded-Host $host;
      34. proxy_set_header X-Forwarded-Server $host;
      35. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      36. proxy_pass http://localhost:600; }
      37. }
      Display All


      Source Code

      1. server
      2. {
      3. listen 80;
      4. server_name mydomain.com;
      5. location / { proxy_set_header X-Real-IP $remote_addr;
      6. proxy_set_header X-Forwarded-For $remote_addr;
      7. proxy_set_header Host $host;
      8. proxy_pass http://127.0.0.1:580; }
      9. }
      10. server
      11. {
      12. listen 443;
      13. server_name mydomain.com;
      14. location / { proxy_set_header X-Real-IP $remote_addr;
      15. proxy_set_header X-Forwarded-For $remote_addr;
      16. proxy_set_header Host $host; proxy_pass http://127.0.0.1:543; }
      17. }
      18. server
      19. {
      20. listen 80;
      21. server_name oc.mydomain.com;
      22. location / { proxy_set_header X-Real-IP $remote_addr;
      23. proxy_set_header X-Forwarded-For $remote_addr;
      24. proxy_set_header Host $host;
      25. proxy_pass http://127.0.0.1:8443; }
      26. }
      27. server
      28. {
      29. listen 443;
      30. server_name oc.mydomain.com;
      31. location / { proxy_set_header X-Real-IP $remote_addr;
      32. proxy_set_header X-Forwarded-For $remote_addr;
      33. proxy_set_header Host $host;
      34. proxy_pass http://127.0.0.1:8443; }
      35. }
      36. server
      37. {
      38. listen 80;
      39. server_name blog.mydomain.com;
      40. location / { proxy_set_header X-Real-IP $remote_addr;
      41. proxy_set_header X-Forwarded-For $remote_addr;
      42. proxy_set_header Host $host;
      43. proxy_pass http://127.0.0.1:680; }
      44. }
      Display All
    • Hi you need to supply the SSL certificates alongside OMV reverse proxy information. If you still need help let me know.


      Also you will need to generate a certificate for mydomain.com, not your openmediavault local hostname (if it was openmediavault.local for the SSL, visiting via mydomain.com will always give warnings)
      :cursing: Intel NUC Kit DE3815TYKHE My NAS build / ARK
      Atom E3815 1.46GHz4GB RAM • 1TB SSHD • 4GB eMMC
      OMV 3.x | OMV-Extras | Flash Memory | Pi-hole

      RPi/3 №1: LibreElec 8.xRPi/3 №2: SickRage, PiVPN, noip2