nginx 配置使用80端口,自动跳转到欢迎页面(welcome to nginx!),但是其他端口可以正常使用
配置文件目录:
/etc/nginx/sites-enables/
在这个目录下面除了在自己写的配置文件(×××.conf)外还有一个default文件,这个文件是默认加载的而配置文件,编辑这个default文件,打开以后是这样的:
编辑default中的80端口,将其改为其他不经常用的端口。最后重启nginx,nginx -s reload 即可
nginx重定向与端口映射,反向代理,外网访问内网问题
server { listen 80; access_log /var/log/nginx/statistics_cwtc_access.log; client_max_body_size 4G; fastcgi_buffers 64 8K; client_body_buffer_size 1024k; keepalive_timeout 5; client_body_timeout 15; client_header_timeout 15; send_timeout 15; sendfile on; tcp_nopush on; tcp_nodelay on; location ~ ^/(docs|uploads|service|bms_backend|manage|system|accounts|wechat) { include uwsgi_params; uwsgi_pass uwsgi://127.0.0.1:18567; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location /bms-api/ { rewrite ^/bms-api/(.*) /$1 break; include uwsgi_params; uwsgi_pass uwsgi://127.0.0.1:18567; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location ~ ^/dashboard(/.*) { root /srv/lr-guomao/guomao_fe/dist; try_files $1 /index.html =404; } location ~ ^/wx(/.*) { root /srv/lr-guomao/guomao_fe/dist; try_files $1 /index.html =404; } location / { # rewrite ^/$ http://www.baidu.com redirect; # include uwsgi_params; # uwsgi_pass uwsgi://127.0.0.1:18567; 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_pass http://172.16.35.253:8080; } }
原文:https://www.cnblogs.com/weidaijie/p/12395937.html