OPNsense
  • Home
  • Help
  • Search
  • Login
  • Register

  • OPNsense Forum »
  • English Forums »
  • Web Proxy Filtering and Caching (Moderator: fabian) »
  • nginx default_server
« previous next »
  • Print
Pages: [1] 2

Author Topic: nginx default_server  (Read 4221 times)

Tubs

  • Jr. Member
  • **
  • Posts: 84
  • Karma: 1
    • View Profile
nginx default_server
« on: September 27, 2020, 03:27:15 am »
Hello,

is there a possibility to specify the "default_server" in the nginx module?

I use more than on http(s) server in direction WAN as well multiple servers as upload servers. Routing is done by domain name and by parameter "servername". All works fine. But if someone accesses my server by IP address I would like to point to a specific upload server. In nginx config I would realise this by the parameter "default_server". Currently any upload server is called, but always the same.

Is it possible to do specify the default server?
What is current logic the upload server is getting selected in case if access by IP?
Logged

fabian

  • Moderator
  • Hero Member
  • *****
  • Posts: 2738
  • Karma: 195
  • OPNsense Contributor (Language, VPN, Proxy, etc.)
    • View Profile
    • Personal Homepage
Re: nginx default_server
« Reply #1 on: September 27, 2020, 11:11:35 pm »
As far as I know, it chooses the first server that is in your generated config. That order likely matches your config.xml file. There is no control in the UI.
Logged

Fright

  • Hero Member
  • *****
  • Posts: 1211
  • Karma: 95
    • View Profile
Re: nginx default_server
« Reply #2 on: September 28, 2020, 12:16:50 pm »
Quote
But if someone accesses my server by IP address
you can also add server with your ip in server_name
Logged

Tubs

  • Jr. Member
  • **
  • Posts: 84
  • Karma: 1
    • View Profile
Re: nginx default_server
« Reply #3 on: October 04, 2020, 07:55:09 am »
Quote from: fabian on September 27, 2020, 11:11:35 pm
As far as I know, it chooses the first server that is in your generated config. That order likely matches your config.xml file. There is no control in the UI.

This could be. At least the server shown by access via IP is the first one that is listed on the configuration page of nginx plugin.

If there now would be an easy way in nginx plugin to change the order without deleting and re-creating everything would be great and solve the issue.
Logged

Tubs

  • Jr. Member
  • **
  • Posts: 84
  • Karma: 1
    • View Profile
Re: nginx default_server
« Reply #4 on: October 04, 2020, 07:56:50 am »
Quote from: Fright on September 28, 2020, 12:16:50 pm
Quote
But if someone accesses my server by IP address
you can also add server with your ip in server_name

Thank you. I did not know this.
But unfortunately in my case difficult due to dynamic IP on my home set-up.
Logged

fabian

  • Moderator
  • Hero Member
  • *****
  • Posts: 2738
  • Karma: 195
  • OPNsense Contributor (Language, VPN, Proxy, etc.)
    • View Profile
    • Personal Homepage
Re: nginx default_server
« Reply #5 on: October 04, 2020, 11:28:12 am »
You can use dynamic dns providers if you like to make it easier to call it anyway.
Logged

Fright

  • Hero Member
  • *****
  • Posts: 1211
  • Karma: 95
    • View Profile
Re: nginx default_server
« Reply #6 on: October 04, 2020, 04:43:31 pm »
Quote
difficult due to dynamic IP on my home set-up
strange that someone is knocking on the dynamic IP )
also you can try to use regexp in server_name directive to catch requests with ip in HOST.
but i think that GUI will not allow you to insert regex for "any ip" (like "^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$")
you can try to use regex for "any" (like "^(.+)$"). in both cases there will be problems with the names of the log-files (need to do something with log-files names in http.conf template)
or
you can look at using $http_host variable with rewrite directive (just guessing. haven't tried any of this)
« Last Edit: October 04, 2020, 04:55:47 pm by Fright »
Logged

Tubs

  • Jr. Member
  • **
  • Posts: 84
  • Karma: 1
    • View Profile
Re: nginx default_server
« Reply #7 on: October 05, 2020, 01:51:16 pm »
Quote from: fabian on October 04, 2020, 11:28:12 am
You can use dynamic dns providers if you like to make it easier to call it anyway.

Maybe I was misleading you.

All is fine when using host name even whit dynamic address. I am not intending to call my server by IP.

But if someone does call my server by IP, the response should be a specific server and not the one that currently is shown.

Logged

Ichotolot85

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
    • View Profile
Re: nginx default_server
« Reply #8 on: December 30, 2020, 06:01:12 pm »
Hello all, this text is translated with deepl, i am not very good at writing english.

Are you any further along with this problem?
I have the exact same problem as Tubs. All unspecified requests are directed to a "default_server", for me nas.domain.
Example:
fhem.domain -> server available -> correct forwarding.
nas.domain -> server available -> correct forwarding
vpn.domain -> service available (1194) -> forwarding at 443 goes to nas.domain
public IP -> forwarded to nas.domain (but it has no NGINX entry)
opnsense.domain -> forwarded to nas.domain

I have tried many things but cannot stop this forwarding. What I noticed is that it has an * entry in the data traffic statistics under server zones.

Is this possibly a bug?
Logged

Fright

  • Hero Member
  • *****
  • Posts: 1211
  • Karma: 95
    • View Profile
Re: nginx default_server
« Reply #9 on: December 30, 2020, 08:31:00 pm »
no. not a bug. its how nginx works
just add new "server" with IP in name field
https://forum.opnsense.org/index.php?topic=20329.0
Logged

Ichotolot85

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
    • View Profile
Re: nginx default_server
« Reply #10 on: December 31, 2020, 04:05:05 pm »
Thanks for the information and the link, hope it helps me.
Logged

bimbar

  • Full Member
  • ***
  • Posts: 175
  • Karma: 7
    • View Profile
Re: nginx default_server
« Reply #11 on: January 03, 2022, 06:32:37 pm »
The default_server option has been implemented in 21.7.7.
Logged

8191

  • Jr. Member
  • **
  • Posts: 79
  • Karma: 4
    • View Profile
Re: nginx default_server
« Reply #12 on: January 04, 2022, 09:05:15 pm »
Quote from: bimbar on January 03, 2022, 06:32:37 pm
The default_server option has been implemented in 21.7.7.
Unfortunately only for http - for https it's still missing. See https://github.com/opnsense/plugins/issues/2741
Logged

Fright

  • Hero Member
  • *****
  • Posts: 1211
  • Karma: 95
    • View Profile
Re: nginx default_server
« Reply #13 on: January 05, 2022, 04:11:12 pm »
@8191
Hi!. I see that the pr has already been merged. it seems to me or have now forgotten about the "proxy_protocol"?  ;)
Logged

bimbar

  • Full Member
  • ***
  • Posts: 175
  • Karma: 7
    • View Profile
Re: nginx default_server
« Reply #14 on: January 05, 2022, 04:42:30 pm »
Does that even make sense for https? I intentionally only implemented it for http.
Logged

  • Print
Pages: [1] 2
« previous next »
  • OPNsense Forum »
  • English Forums »
  • Web Proxy Filtering and Caching (Moderator: fabian) »
  • nginx default_server
 

OPNsense is an OSS project © Deciso B.V. 2015 - 2022 All rights reserved
  • SMF 2.0.18 | SMF © 2021, Simple Machines
    Privacy Policy
    | XHTML | RSS | WAP2