首页天道酬勤centos启动nginx,centos端口映射

centos启动nginx,centos端口映射

张世龙 05-12 17:06 128次浏览

虽然在CentOS系统上建立了许多站点,但是为了在不同的站点上共享80个端口,可以使用Nginx端口听歌电话功能,将80个端口按域名映射到多个端口。

yum install nginx -y

设置端口爱听电话

以下是hdsdl/etc/nginx/conf.d目录的默认文件:

总体12

- rw-r---r----1root root 1290 jun 1705336034 default.conf

-rw-r----r----1根466jun1705336034SSL.conf

- rw-r---r----1root root 283 jun 1705336034 virtual.conf

proxy_redirect off;

proxy_set_header Host $host;

proxy _ set _ headerx-real-IP $ remote _ addr;

proxy _ set _ headerx-forwarded-for $ proxy _ add _ x _ forwarded _ for;

client_max_body_size 10m;

client_body_buffer_size 128k;

proxy_connect_timeout 90;

proxy_send_timeout 90;

proxy_read_timeout 90;

proxy_buffer_size 4k;

proxy_buffers 4 32k;

proxy_busy_buffers_size 64k;

proxy_temp_file_write_size 64k;

#用户nobody;

工作器_ processes 1;

error_log logs/error.log;

#error_log logs/error.log notice;

#error_log logs/error.log info;

pid logs/nginx.pid;

事件{

worker_connections 64;

}

http {

include mime.types;

efault _ type应用程序/octet-stream;

log _ format main ' $ remote _ addr-$ remote _ user [ $ time _ local ] $ request '

# ' ' $ status ' $ body _ bytes _ sent ' $ http _ referer ' '

# ' ' $ http _ user _ agent ' ' $ http _ x _ forwarded _ for ';

access_log logs/access.log main;

sendfile on;

#tcp_nopush on;

#keepalive_timeout 0;

keepalive_timeout 100;

#设置请求缓存

client_header_buffer_size 2k;

large_client_header_buffers 4 4k;

#打开gzip模型

gzip on;

gzip_min_length 1100;

gzip_buffers 4 8k;

gzip_types text/plain;

output_buffers 1 32k;

postpone_output 1460;

upstream www.qikemi.com {

server 127.0.0.1:8085;

}

upstream www.xiexianbin.cn {

server 127.0.0.1:8086;

}

upstream www.xiaohua.asia {

server 127.0.0.1:8087;

}

服务器{

listen 80

p>

server_name www.qikemi.com;

#charset koi8-r;

access_log logs/hostqikemi.access.log main;

#root html;

#index index.html index.htm;

proxy_pass http://www.qikemi.com;

include proxy.conf;

}

}

server {

listen 80;

server_name www.xiexianbin.cn;

#charset koi8-r;

access_log logs/host166801.access.log main;

#root html;

#index index.html index.htm;

proxy_pass http://www.xiexianbin.cn;

include proxy.conf;

expires 30d;

}

}

server {

listen 80;

server_name www.xiaohua.asia;

#charset koi8-r;

access_log logs/hostxiaohua.access.log main;

#root html;

#index index.html index.htm;

proxy_pass http://www.xiaohua.asia;

include proxy.conf;

expires 30d;

}

}

}

或kydqz/etc/nginx/conf.d中直接添加自己需要配置,如下:

upstream cas.qikemi.com {

server 127.0.0.1:8084;

}

server {

listen 80;

server_name cas.qikemi.com;

#ssl on;

#charset koi8-r;

access_log logs/cas.qikemi.com.access.log main;

### SSL cert files ###

#ssl_certificate /var/local/github/ssl/qikemi.com/1_www.qikemi.com_bundle.crt;

#ssl_certificate_key /var/local/github/ssl/qikemi.com/2_www.qikemi.com.key;

### Add SSL specific settings here ###

#keepalive_timeout 60;

#root html;

#index index.html index.htm;

proxy_pass http://cas.qikemi.com;

proxy_next_upstream error timeout invalid_header http_500 http_502 http_503;

include /etc/nginx/conf.d/proxy.conf;

proxy_set_header X-Forwarded-Proto https;

}

}

upstream shop.qikemi.com {

server 127.0.0.1:8082;

#server xiexianbin.github.io;

}

server {

listen 80;

server_name shop.qikemi.com;

#ssl on;

#charset koi8-r;

access_log logs/shop.qikemi.com.access.log main;

### SSL cert files ###

#ssl_certificate /var/local/github/ssl/qikemi.com/1_shop.qikemi.com_bundle.crt;

#ssl_certificate_key /var/local/github/ssl/qikemi.com/2_shop.qikemi.com.key;

### Add SSL specific settings here ###

#keepalive_timeout 60;

#root html;

#index index.html index.htm;

proxy_pass http://shop.qikemi.com;

proxy_next_upstream error timeout invalid_header http_500 http_502 http_503;

include /etc/nginx/conf.d/proxy.conf;

proxy_set_header X-Forwarded-Proto https;

}

}

upstream www.xiexianbin.cn {

server 127.0.0.1:8081;

#server xiexianbin.github.io;

}

server {

listen 80;

server_name www.xiexianbin.cn;

rewrite ^(.*) https://$server_name$1 permanent;

}

server {

listen 80;

server_name xiexianbin.cn;

rewrite ^(.*) https://www.xiexianbin.cn permanent;

}

server {

server_name www.xiexianbin.cn;

ssl on;

#charset koi8-r;

access_log logs/www.xiexianbin.cn.access.log main;

### SSL cert files ###

ssl_certificate /var/local/github/ssl/xiexianbin_cn/1_www.xiexianbin.cn_bundle.crt;

ssl_certificate_key /var/local/github/ssl/xiexianbin_cn/2_www.xiexianbin.cn.key;

### Add SSL specific settings here ###

keepalive_timeout 60;

#root html;

#index index.html index.htm;

proxy_pass http://www.xiexianbin.cn;

proxy_next_upstream error timeout invalid_header http_500 http_502 http_503;

include /etc/nginx/conf.d/proxy.conf;

proxy_set_header X-Forwarded-Proto https;

}

}

linux下nginx安装配置,nginx根据域名转发tcp nginx转发https,https请求转发http