我在我的Mac上开发了一个网络产品。我需要运行sudo PORT=8000 HTTPS=true SSL_CRT_FILE=ssl/localhost-mac/cert.pem SSL_KEY_FILE=ssl/localhost-mac/key.pem ./node_modules/.bin/react-scripts start
来启动前端。结果,例如,https://localhost:8000/#/home
启动主页。
我也在我的Mac上开发后端。在另一个文件夹中,我需要运行yarn start
。然后,https://localhost:3000
服务来自前端的请求。目前,前端和后端工作得很好。
当前/usr/local/etc/nginx/nginx.conf
如下。请注意,443有一个服务器块; 8000没有服务器块。
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
log_format my_log '{ "time": "$time_iso8601", '
'"remote_addr": "$remote_addr", '
'"status": "$status", '
'"request": "$request", '
'"request_method": "$request_method", '
'"http_referrer": "$http_referer", '
'"http_x_forwarded_for": "$http_x_forwarded_for", '
'"host": "$host", '
'"server_name": "$server_name", '
'"upstream_address": "$upstream_addr", '
'"upstream_status": "$upstream_status" }';
access_log /usr/local/var/log/nginx/access.log;
upstream videohint {
# server 167.172.58.156:443;
server localhost:3000;
}
server {
listen 443 ssl;
server_name localhost;
ssl_certificate /etc/ssl/localhost/localhost.crt;
ssl_certificate_key /etc/ssl/localhost/localhost.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_session_timeout 1d;
ssl_stapling off;
ssl_stapling_verify off;
add_header Strict-Transport-Security max-age=15768000;
add_header X-Frame-Options "";
proxy_ssl_name "www.videohint.com";
proxy_ssl_server_name on;
location ~ /socialLoginSuccess {
return 301 https://$host:8000/#/socialLoginSuccess;
}
location ~ /auth/(.*) {
proxy_pass https://videohint/key/auth/$1?$query_string;
proxy_set_header Host localhost;
}
location / {
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Accept-Encoding "";
proxy_set_header Proxy "";
proxy_pass https://localhost:8000/;
# proxy_pass https://www.bing.com/
# These three lines added as per https://github.com/socketio/socket.io/issues/1942 to remove socketio error
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
include servers/*;
}
我有一些特殊的需要。我希望一切工作像以前一样,除了https://localhost:8000/stripe_checkout/...
的要求;我想将https://localhost:8000/stripe_checkout/...
的请求重定向到https://checkout.stripe.com/...
。
有人知道怎么做吗?
1条答案
按热度按时间hmae6n7t1#
尝试将上面的代码**添加到
location / {.....}
中