R
R
redbutcold2012-12-25 18:59:35
Nginx
redbutcold, 2012-12-25 18:59:35

NGINX > what is the fastest way to change the port for all virtual hosts???

what is a quick way to change the port in the config for all virtual hosts??
there are sites and they are all on port 80, you need to transfer them to 8080. There are 10 sites, but if you change your fingers every time you break ... I just thought I never encountered it.
echo listen 8080; >> /etc/nginx/ports.conf??
server {
include /etc/nginx/ports.conf;
server_name yourdomain.com;
??

Answer the question

In order to leave comments, you need to log in

6 answer(s)
V
VBart, 2012-12-25
@VBart

sed, awk… and no need to reinvent the wheel.

P
Puma Thailand, 2012-12-26
@opium

Manually change and save two versions of configs, when necessary, copy the necessary configs.

A
Alexey Akulovich, 2012-12-25
@AterCattus

Roughly speaking, something like this:

awk '{gsub(/^listen[ \t]+.+$/, "listen 127.0.0.1:8080;");} 1' /path/to/nginx_server.conf

M
Maxim, 2012-12-26
@maxout

well the variant with include will work, to what a question?

S
Sergey, 2012-12-26
@bondbig

why constantly change the port? What is the task? Maybe we can suggest a better way to solve it.
If you change it one-time, then sed, as already said, if (why?) constantly change back and forth, then you just need to initially write the config with this in mind and use the voiced include functionality.
But I still doubt that there is really a need to constantly change the port.

V
Viktor Taran, 2014-02-07
@shambler81

Doumab balancer is much better for this.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question