Unfortunately neither suggestion seems to be working, it still infinitely 301's.
Here is my hostingConfig:
"HostingConfig": {
"UseProxy": true,
"ForwardedProtoHeaderName": "",
"ForwardedForHeaderName": "",
"KnownProxies": ""
},
And my full nginx config: (Removing the first 2 server blocks doesn't change anything, they're to remove the WWW and switch http to https, respectively)
server {
server_name www.my-site.com;
return 301 $scheme://my-site.com$request_uri;
}
server {
listen 80;
listen [::]:80;
server_name my-site.com;
location / {
return 301 https://$host$request_uri;
}
}
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name my-site.com;
ssl_certificate /etc/letsencrypt/live/my-site.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/my-site.com/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
location / {
proxy_pass http://nopcommerce_web; # DNS resolves name to nop server
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
And here is the full code that gets repeated each time the server receives a request, it gets repeated about 10 times or so:
nopcommerce_nginx | 45.132.227.30 - - [08/Apr/2022:20:17:56 +0000] "GET / HTTP/1.1" 301 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:99.0) Gecko/20100101 Firefox/99.0" "-"
nopcommerce_web | {"EventId":1,"LogLevel":"Information","Category":"Microsoft.AspNetCore.Hosting.Diagnostics","Message":"Request starting HTTP/1.1 GET http://my-site.com/ - -","State":{"Message":"Request starting HTTP/1.1 GET http://my-site.com/ - -","Protocol":"HTTP/1.1","Method":"GET","ContentType":null,"ContentLength":null,"Scheme":"http","Host":"my-site.com","PathBase":"","Path":"/","QueryString":""}}
nopcommerce_web | {"EventId":0,"LogLevel":"Information","Category":"Microsoft.AspNetCore.Routing.EndpointMiddleware","Message":"Executing endpoint \u0027Nop.Web.Controllers.HomeController.Index (Nop.Web)\u0027","State":{"Message":"Executing endpoint \u0027Nop.Web.Controllers.HomeController.Index (Nop.Web)\u0027","EndpointName":"Nop.Web.Controllers.HomeController.Index (Nop.Web)","{OriginalFormat}":"Executing endpoint \u0027{EndpointName}\u0027"}}
nopcommerce_web | {"EventId":3,"LogLevel":"Information","Category":"Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker","Message":"Route matched with {action = \u0022Index\u0022, controller = \u0022Home\u0022, area = \u0022\u0022}. Executing controller action with signature Microsoft.AspNetCore.Mvc.IActionResult Index() on controller Nop.Web.Controllers.HomeController (Nop.Web).","State":{"Message":"Route matched with {action = \u0022Index\u0022, controller = \u0022Home\u0022, area = \u0022\u0022}. Executing controller action with signature Microsoft.AspNetCore.Mvc.IActionResult Index() on controller Nop.Web.Controllers.HomeController (Nop.Web).","RouteData":"{action = \u0022Index\u0022, controller = \u0022Home\u0022, area = \u0022\u0022}","MethodInfo":"Microsoft.AspNetCore.Mvc.IActionResult Index()","Controller":"Nop.Web.Controllers.HomeController","AssemblyName":"Nop.Web","{OriginalFormat}":"Route matched with {RouteData}. Executing controller action with signature {MethodInfo} on controller {Controller} ({AssemblyName})."}}
nopcommerce_web | {"EventId":3,"LogLevel":"Information","Category":"Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker","Message":"Authorization failed for the request at filter \u0027Nop.Web.Framework.Mvc.Filters.HttpsRequirementAttribute\u002BHttpsRequirementFilter\u0027.","State":{"Message":"Authorization failed for the request at filter \u0027Nop.Web.Framework.Mvc.Filters.HttpsRequirementAttribute\u002BHttpsRequirementFilter\u0027.","AuthorizationFilter":"Nop.Web.Framework.Mvc.Filters.HttpsRequirementAttribute\u002BHttpsRequirementFilter","{OriginalFormat}":"Authorization failed for the request at filter \u0027{AuthorizationFilter}\u0027."}}
nopcommerce_web | {"EventId":1,"LogLevel":"Information","Category":"Microsoft.AspNetCore.Mvc.Infrastructure.RedirectResultExecutor","Message":"Executing RedirectResult, redirecting to https://my-site.com/.","State":{"Message":"Executing RedirectResult, redirecting to https://my-site.com/.","Destination":"https://my-site.com/","{OriginalFormat}":"Executing RedirectResult, redirecting to {Destination}."}}
nopcommerce_web | {"EventId":2,"LogLevel":"Information","Category":"Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker","Message":"Executed action Nop.Web.Controllers.HomeController.Index (Nop.Web) in 5.6776ms","State":{"Message":"Executed action Nop.Web.Controllers.HomeController.Index (Nop.Web) in 5.6776ms","ActionName":"Nop.Web.Controllers.HomeController.Index (Nop.Web)","ElapsedMilliseconds":5.6776,"{OriginalFormat}":"Executed action {ActionName} in {ElapsedMilliseconds}ms"}}
nopcommerce_web | {"EventId":1,"LogLevel":"Information","Category":"Microsoft.AspNetCore.Routing.EndpointMiddleware","Message":"Executed endpoint \u0027Nop.Web.Controllers.HomeController.Index (Nop.Web)\u0027","State":{"Message":"Executed endpoint \u0027Nop.Web.Controllers.HomeController.Index (Nop.Web)\u0027","EndpointName":"Nop.Web.Controllers.HomeController.Index (Nop.Web)","{OriginalFormat}":"Executed endpoint \u0027{EndpointName}\u0027"}}
nopcommerce_web | {"EventId":2,"LogLevel":"Information","Category":"Microsoft.AspNetCore.Hosting.Diagnostics","Message":"Request finished HTTP/1.1 GET http://my-site.com/ - - - 301 0 - 13.0938ms","State":{"Message":"Request finished HTTP/1.1 GET http://my-site.com/ - - - 301 0 - 13.0938ms","ElapsedMilliseconds":13.0938,"StatusCode":301,"ContentType":null,"ContentLength":0,"Protocol":"HTTP/1.1","Method":"GET","Scheme":"http","Host":"my-site.com","PathBase":"","Path":"/","QueryString":""}}
nopcommerce_nginx | 45.132.227.30 - - [08/Apr/2022:20:17:56 +0000] "GET / HTTP/1.1" 301 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:99.0) Gecko/20100101 Firefox/99.0" "-"