Skip to content

Commit f00fe27

Browse files
committed
allow ___domain like 'com.example.com:8080',use external port and nginx programmer manager listen thses ports
1 parent fd30cfe commit f00fe27

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

backend/internal/nginx.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@ const internalNginx = {
3232
return internalNginx.deleteConfig(host_type, host); // Don't throw errors, as the file may not exist at all
3333
})
3434
.then(() => {
35+
boolean use_default_port = false;
36+
let listen_ports = [];
37+
_.each(host.domain_names, (domain_name) => {
38+
if ( domain_name.indexOf(":") < 0 ){
39+
host.use_default_port = true;
40+
}else{
41+
let listen_port = parseInt(domain_name.substring(domain_name.indexOf(":")+1));
42+
}
43+
});
44+
3545
return internalNginx.generateConfig(host_type, host);
3646
})
3747
.then(() => {

backend/templates/_listen.conf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,7 @@
1212
#listen [::]:443;
1313
{% endif %}
1414
{% endif %}
15+
{% for listen_port in listen_ports %}
16+
listen listen_port;
17+
{% endfor %}
1518
server_name {{ domain_names | join: " " }};

backend/templates/proxy_host.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ proxy_http_version 1.1;
5656
{% if allow_websocket_upgrade == 1 or allow_websocket_upgrade == true %}
5757
proxy_set_header Upgrade $http_upgrade;
5858
proxy_set_header Connection $http_connection;
59+
proxy_set_header Host $host:$server_port;
5960
proxy_http_version 1.1;
6061
{% endif %}
6162

0 commit comments

Comments
 (0)