1 Star 2 Fork 0

郭瀚亭/工具人的工具箱-MyTools

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
nginx.conf 3.43 KB
一键复制 编辑 原始数据 按行查看 历史
郭瀚亭 提交于 2023-01-23 11:34 . 优化nginx配置
# django连接组件
upstream django1{
server unix:///tmp/uwsgi_1.sock; # sock,名字随意,后边要保持一致
}
server {
listen 80; # http
server_name guohtgo.asuscomm.com;
set $flag 0;
# 禁止ip访问
if ($host != 'guohtgo.asuscomm.com'){
# return 403;
set $flag "${flag}1";
}
if ($host != '192.168.1.30'){
# return 403;
set $flag "${flag}1";
}
if ($flag = "011"){
return 403;
}
rewrite ^(.*) http://$server_name:8001$1 permanent; #或者 rewrite ^(.*) https://$host$1 permanent
}
server {
listen 443 ssl; # https
server_name guohtgo.asuscomm.com;
set $flag 0;
# 禁止ip访问
if ($host != 'guohtgo.asuscomm.com'){
# return 403;
set $flag "${flag}1";
}
if ($host != '192.168.1.30'){
# return 403;
set $flag "${flag}1";
}
if ($flag = "011"){
return 403;
}
rewrite ^(.*) https://$server_name:8002$1 permanent; #或者 rewrite ^(.*) https://$host$1 permanent
}
server {
listen 8001; # http
server_name guohtgo.asuscomm.com;
set $flag 0;
# 禁止ip访问
if ($host != 'guohtgo.asuscomm.com'){
# return 403;
set $flag "${flag}1";
}
if ($host != '192.168.1.30'){
# return 403;
set $flag "${flag}1";
}
if ($flag = "011"){
return 403;
}
rewrite ^(.*) https://$server_name:8002$1 permanent; #或者 rewrite ^(.*) https://$host$1 permanent
}
server {
# 监视的网站端口
listen 8002 ssl; # https
server_name guohtgo.asuscomm.com;
set $flag 0;
#禁止ip访问
if ($host != 'guohtgo.asuscomm.com'){
# return 403;
set $flag "${flag}1";
}
if ($host != '192.168.1.30'){
# return 403;
set $flag "${flag}1";
}
if ($flag = "011"){
return 403;
}
#ssl on;
ssl_certificate /etc/nginx/ssl/server.crt;
ssl_certificate_key /etc/nginx/ssl/server.key;
#UTF-8编码
charset utf-8;
# 最大上传大小128M,可自由定义
client_max_body_size 900M;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
uwsgi_param X-Real-IP $remote_addr;
uwsgi_param X-Forwarded-For $proxy_add_x_forwarded_for;
uwsgi_param X-Forwarded-Proto $http_x_forwarded_proto;
# 媒体文件(上传)
location /upload_files {
alias /home/pi/Code/Django_proj/MyTools/upload_files; # 不在静态文件中
}
# 页面icon
location /favicon.ico {
alias /home/pi/Code/Django_proj/MyTools/static/img/tools-icon.png;
}
# 静态文件
location /static {
alias /home/pi/Code/Django_proj/MyTools/static;
}
# 其他交由django处理
location / {
uwsgi_param X-Real-IP $remote_addr;
uwsgi_param X-Forwarded-For $proxy_add_x_forwarded_for;
uwsgi_param X-Forwarded-Proto $http_x_forwarded_proto;
uwsgi_pass django1;
include uwsgi_params; # uwsgi
proxy_set_header Host $http_host;
}
location /webssh/ {
proxy_pass http://127.0.0.1:8888/;
proxy_http_version 1.1;
proxy_read_timeout 300;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Real-PORT $remote_port;
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/guo-hanting/my-tools-all.git
git@gitee.com:guo-hanting/my-tools-all.git
guo-hanting
my-tools-all
工具人的工具箱-MyTools
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385