uwsgi+nginx+vue
原http协议换成https协议出现问题
还有跨域问题(咋配置)
[uwsgi]
uid=mlh
socket=192.168.134.128:8000
chdir=/home/mlh/run_sth/water_quality_gradution
module=wsgi.py
home=/home/mlh/run_sth/water_quality_gradution/venv
wsgi-file=water_quality/wsgi.py
process=3
thread=3
# daemonize=uwsgi.log
pidfile=uwsgiPid.log
master=True
buffer-size=65536
disable-logging=false
enable-threads=true
thunder-lock=true
protocol=http
server {
listen 443 default ssl;
ssl On;
ssl_certificate 7775973_www.mlhtest.xyz.pem;
ssl_certificate_key 7775973_www.mlhtest.xyz.key;
server_name www.mlhtest.xyz;
location /dist/ {
root /home/mlh/run_sth/water-quality-web;
}
location / {
proxy_pass http://apiserver;
proxy_set_header Host $host;
}
}
server {
listen 80;
server_name www.mlhtest.xyz;
location / {
rewrite ^(.*) https://$server_name$1 redirect;
}
}
跨域,到底该怎么配置,crazy!
原http替换为https且正常运行
nginx配置不熟悉,网络请求原理不懂,跨域概念模糊,难以下手。
我q 2698298656,在线等大佬调教。
worker_processes 2; # 启动两个Nginx worker 进程
events {
# 每个工作进程 可以同时接收 1024 个连接
worker_connections 1024;
}
# 配置 Nginx worker 进程 最大允许 2000个网络连接
worker_rlimit_nofile 2000;
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 30;
gzip on;
# 配置 HTTP 服务器信息
server {
# 配置网站的域名,这里请改为你申请的域名, 如果没有域名,使用IP地址。
rewrite ^(.*)$ https://$host$1 permanent;
}
server {
listen 443 ssl;
server_name www.mlhtest.xyz;
ssl_certificate 7775973_www.mlhtest.xyz.pem;
ssl_certificate_key 7775973_www.mlhtest.xyz.key;
location / {
uwsgi_pass 127.0.0.1:8000;
include /etc/nginx/uwsgi_params;
}
location /dist/ {
root /home/mlh/run_sth/water-quality-web;
}
}
}
更改为https协议后:was loaded over HTTPS, but requested an insecure错误解决
https://blog.csdn.net/weixin_40918067/article/details/117839199
有更加详细的报错没,感觉只是这个报错信息看不出来什么
这边帮你看一下,一般只是nginx方便加下ssl证书配置就可以了,其它的不变。
检查证书路径是否正确
重启服务后看是否异常,如果确定无问题,再仔细检查Nginx配置文件。server同级的location放在server 试下。
参照如下
#user nobody;
worker_processes 4;
error_log /Users/valley/webserver/nginx/logs/error.log crit;
#error_log logs/error.log notice;
#error_log logs/error.log info;
pid /Users/valley/webserver/nginx/logs/nginx.pid;
worker_rlimit_nofile 65535;
events {
use epoll;
worker_connections 10240;
}
http {
include mime.types;
default_type application/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"';
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;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 200m;
sendfile on;
tcp_nopush on;
keepalive_timeout 60;
tcp_nodelay on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|ico)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 15d;
# access_log off;
}
access_log off;
}
server {
listen 443 ssl;
server_name www.sample.com;
ssl_certificate sample/sample.pem;
ssl_certificate_key sample/sample.key; ssl_prefer_server_ciphers on;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers "HIGH:!aNULL:!MD5";
add_header X-Frame-Options DENY;
add_header X-Content-Type-Options nosniff;
add_header X-Xss-Protection 1;
location / {
proxy_pass http://localhost:8080;
proxy_set_header Host $proxy_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
}