Last active
January 17, 2022 18:29
-
-
Save dlangille/f93b2edf91da919a8ad1410671c9dddc to your computer and use it in GitHub Desktop.
nginx reverse proxy for unifi controller, so you can put a real cert in front of it.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# listen on port 80, and redirect to port 443 | |
server { | |
listen 10.0.0.131:80; | |
server_name unifi01.int.unixathome.org; | |
error_log /var/log/nginx-unifi01.int.unixathome.org.error.log info; | |
access_log /var/log/nginx-unifi01.int.unixathome.org.access.log combined; | |
return 301 https://$server_name$request_uri; | |
} | |
server { | |
listen 10.55.0.131:443 ssl http2; | |
server_name unifi01.int.unixathome.org; | |
client_max_body_size 50m; | |
root /usr/local/www/unifi01.int.unixathome.org; | |
error_log /var/log/nginx-unifi01.int.unixathome.org.error.log info; | |
access_log /var/log/nginx-unifi01.int.unixathome.org.access.log combined; | |
ssl_certificate /usr/local/etc/ssl/unifi01.int.unixathome.org.fullchain.cer; | |
ssl_certificate_key /usr/local/etc/ssl/unifi01.int.unixathome.org.key; | |
location / { | |
proxy_pass https://unifi01.int.unixathome.org:8443/; | |
proxy_redirect https://unifi01.int.unixathome.org:8443/ /; | |
proxy_buffering off; | |
proxy_read_timeout 60s; | |
# May not need or want to set Host. Should default to the above hostname. | |
proxy_set_header Host $host; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_http_version 1.1; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection "Upgrade"; | |
} | |
} |
@dlangille any ideas how to use subfolder location for this?
location /unifi {
....
}
returns 404 for me.
Thank you for this! All the other advice out there seemed to not fix the websocket error you mentioned.
@dlangille any ideas how to use subfolder location for this?
location /unifi { .... }
returns 404 for me.
Sorry, I only just saw this. Is it working yet for you?
Thank you for this! All the other advice out there seemed to not fix the websocket error you mentioned.
I'm happy it helps you. This solution is still in use at my place.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Lines 43-45 avoid the 'Websocket connection error' messages. Those message coincide with Javascript console messages such as:
The original revision of this file separately proxied /wss ; I found that to be unnecessary.